Class FSHLog.RingBufferEventHandler
- All Implemented Interfaces:
com.lmax.disruptor.EventHandler<RingBufferTruck>,com.lmax.disruptor.LifecycleAware
- Enclosing class:
- FSHLog
Herein, we have an array into which we store the sync futures as they come in. When we have a
'batch', we'll then pass what we have collected to a SyncRunner thread to do the filesystem
sync. When it completes, it will then call SyncFuture.done(long, Throwable) on each of
SyncFutures in the batch to release blocked Handler threads.
I've tried various effects to try and make latencies low while keeping throughput high. I've tried keeping a single Queue of SyncFutures in this class appending to its tail as the syncs coming and having sync runner threads poll off the head to 'finish' completed SyncFutures. I've tried linkedlist, and various from concurrent utils whether LinkedBlockingQueue or ArrayBlockingQueue, etc. The more points of synchronization, the more 'work' (according to 'perf stats') that has to be done; small increases in stall percentages seem to have a big impact on throughput/latencies. The below model where we have an array into which we stash the syncs and then hand them off to the sync thread seemed like a decent compromise. See HBASE-8755 for more detail.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ExceptionSet if we get an exception appending or syncing so that all subsequence appends and syncs on this WAL fail until WAL is replaced.private final ObjectObject to block on while waiting on safe point.private booleanprivate final SyncFuture[]private AtomicIntegerprivate intWhich syncrunner to use next.private final FSHLog.SyncRunner[]private FSHLog.SafePointZigZagLatch -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidappend(FSWALEntry entry) Append to the WAL.(package private) FSHLog.SafePointZigZagLatchprivate voidattainSafePoint(long currentSequence) Check if we should attain safe point.private voidcleanupOutstandingSyncsOnException(long sequence, Exception e) private booleanReturns True if outstanding sync futures stillprivate booleanprivate voidOffers the finished syncs back to the cache for reuse.voidonEvent(RingBufferTruck truck, long sequence, boolean endOfBatch) voidvoidonStart()
-
Field Details
-
syncRunners
-
syncFutures
-
syncFuturesCount
-
zigzagLatch
-
exception
Set if we get an exception appending or syncing so that all subsequence appends and syncs on this WAL fail until WAL is replaced. -
safePointWaiter
Object to block on while waiting on safe point. -
shutdown
-
syncRunnerIndex
Which syncrunner to use next.
-
-
Constructor Details
-
RingBufferEventHandler
RingBufferEventHandler(int syncRunnerCount, int maxBatchCount)
-
-
Method Details
-
cleanupOutstandingSyncsOnException
-
offerDoneSyncsBackToCache
Offers the finished syncs back to the cache for reuse. -
isOutstandingSyncs
Returns True if outstanding sync futures still -
isOutstandingSyncsFromRunners
-
onEvent
- Specified by:
onEventin interfacecom.lmax.disruptor.EventHandler<RingBufferTruck>- Throws:
Exception
-
attainSafePoint
-
attainSafePoint
Check if we should attain safe point. If so, go there and then wait till signalled before we proceeding. -
append
Append to the WAL. Does all CP and WAL listener calls.- Throws:
Exception
-
onStart
- Specified by:
onStartin interfacecom.lmax.disruptor.LifecycleAware
-
onShutdown
- Specified by:
onShutdownin interfacecom.lmax.disruptor.LifecycleAware
-