Class FSHLog.SyncRunner
java.lang.Object
java.lang.Thread
org.apache.hadoop.hbase.regionserver.wal.FSHLog.SyncRunner
- All Implemented Interfaces:
Runnable
- Enclosing class:
- FSHLog
Thread to runs the hdfs sync call. This call takes a while to complete. This is the longest
pole adding edits to the WAL and this must complete to be sure all edits persisted. We run
multiple threads sync'ng rather than one that just syncs in series so we have better latencies;
otherwise, an edit that arrived just after a sync started, might have to wait almost the length
of two sync invocations before it is marked done.
When the sync completes, it marks all the passed in futures done. On the other end of the sync future is a blocked thread, usually a regionserver Handler. There may be more than one future passed in the case where a few threads arrive at about the same time and all invoke 'sync'. In this case we'll batch up the invocations and run one filesystem sync only for a batch of Handler sync invocations. Do not confuse these Handler SyncFutures with the futures an ExecutorService returns when you call submit. We have no use for these in this model. These SyncFutures are 'artificial', something to hold the Handler until the filesystem sync completes.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionprivate long
private final BlockingQueue<SyncFuture>
private SyncFuture
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) boolean
(package private) void
offer
(long sequence, SyncFuture[] syncFutures, int syncFutureCount) private int
releaseSyncFuture
(SyncFuture syncFuture, long currentSequence, Throwable t) Release the passedsyncFuture
private int
releaseSyncFutures
(long currentSequence, Throwable t) Release all SyncFutures whose sequence is <=currentSequence
.void
run()
private long
updateHighestSyncedSequence
(long sequence) Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
-
Field Details
-
sequence
-
syncFutures
-
takeSyncFuture
-
-
Constructor Details
-
SyncRunner
SyncRunner(String name, int maxHandlersCount)
-
-
Method Details
-
offer
-
releaseSyncFuture
Release the passedsyncFuture
- Returns:
- Returns 1.
-
releaseSyncFutures
Release all SyncFutures whose sequence is <=currentSequence
.- Parameters:
t
- May be non-null if we are processing SyncFutures because an exception was thrown.- Returns:
- Count of SyncFutures we let go.
-
updateHighestSyncedSequence
- Parameters:
sequence
- The sequence we ran the filesystem sync against.- Returns:
- Current highest synced sequence.
-
areSyncFuturesReleased
boolean areSyncFuturesReleased() -
run
-