private class FSHLog.SyncRunner extends HasThread
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.
Modifier and Type | Field and Description |
---|---|
private long |
sequence |
private BlockingQueue<SyncFuture> |
syncFutures |
private SyncFuture |
takeSyncFuture |
Constructor and Description |
---|
FSHLog.SyncRunner(String name,
int maxHandlersCount)
UPDATE!
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
areSyncFuturesReleased() |
(package private) void |
offer(long sequence,
SyncFuture[] syncFutures,
int syncFutureCount) |
private int |
releaseSyncFuture(SyncFuture syncFuture,
long currentSequence,
Throwable t)
Release the passed
syncFuture |
private int |
releaseSyncFutures(long currentSequence,
Throwable t)
Release all SyncFutures whose sequence is <=
currentSequence . |
void |
run() |
private long |
updateHighestSyncedSequence(long sequence) |
getName, getThread, interrupt, isAlive, isInterrupted, join, join, join, setDaemon, setName, setPriority, setUncaughtExceptionHandler, start
private volatile long sequence
private final BlockingQueue<SyncFuture> syncFutures
private volatile SyncFuture takeSyncFuture
FSHLog.SyncRunner(String name, int maxHandlersCount)
syncs
- the batch of calls to sync that arrived as this thread was starting; when done,
we will put the result of the actual hdfs sync call as the result.sequence
- The sequence number on the ring buffer when this thread was set running.
If this actual writer sync completes then all appends up this point have been
flushed/synced/pushed to datanodes. If we fail, then the passed in syncs
futures will return the exception to their clients; some of the edits may have made it out
to data nodes but we will report all that were part of this session as failed.void offer(long sequence, SyncFuture[] syncFutures, int syncFutureCount)
private int releaseSyncFuture(SyncFuture syncFuture, long currentSequence, Throwable t)
syncFuture
syncFuture
- currentSequence
- t
- private int releaseSyncFutures(long currentSequence, Throwable t)
currentSequence
.currentSequence
- t
- May be non-null if we are processing SyncFutures because an exception was thrown.private long updateHighestSyncedSequence(long sequence)
sequence
- The sequence we ran the filesystem sync against.boolean areSyncFuturesReleased()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.