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
Modifier and TypeFieldDescriptionprivate 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.private final Object
Object to block on while waiting on safe point.private boolean
private final SyncFuture[]
private AtomicInteger
private int
Which syncrunner to use next.private final FSHLog.SyncRunner[]
private FSHLog.SafePointZigZagLatch
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) void
append
(FSWALEntry entry) Append to the WAL.(package private) FSHLog.SafePointZigZagLatch
private void
attainSafePoint
(long currentSequence) Check if we should attain safe point.private void
cleanupOutstandingSyncsOnException
(long sequence, Exception e) private boolean
Returns True if outstanding sync futures stillprivate boolean
private void
Offers the finished syncs back to the cache for reuse.void
onEvent
(RingBufferTruck truck, long sequence, boolean endOfBatch) void
void
onStart()
-
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:
onEvent
in 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:
onStart
in interfacecom.lmax.disruptor.LifecycleAware
-
onShutdown
- Specified by:
onShutdown
in interfacecom.lmax.disruptor.LifecycleAware
-