- java.lang.Object
-
- com.lmax.disruptor.AggregateEventHandler<T>
-
- Type Parameters:
T
- event implementation storing the data for sharing during exchange or parallel coordination of an event.
- All Implemented Interfaces:
EventHandler<T>
,EventHandlerIdentity
public final class AggregateEventHandler<T> extends java.lang.Object implements EventHandler<T>
An aggregate collection ofEventHandler
s that get called in sequence for each event.
-
-
Constructor Summary
Constructors Constructor Description AggregateEventHandler(EventHandler<T>... eventHandlers)
Construct an aggregate collection ofEventHandler
s to be called in sequence.
-
Method Summary
All Methods Instance Methods Concrete Methods Default Methods Modifier and Type Method Description default void
onBatchStart(long batchSize, long queueDepth)
Invoked byBatchEventProcessor
prior to processing a batch of eventsvoid
onEvent(T event, long sequence, boolean endOfBatch)
Called when a publisher has published an event to theRingBuffer
.void
onShutdown()
void
onStart()
default void
onTimeout(long sequence)
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.lmax.disruptor.EventHandler
setSequenceCallback
-
-
-
-
Constructor Detail
-
AggregateEventHandler
@SafeVarargs public AggregateEventHandler(EventHandler<T>... eventHandlers)
Construct an aggregate collection ofEventHandler
s to be called in sequence.- Parameters:
eventHandlers
- to be called in sequence.
-
-
Method Detail
-
onEvent
public void onEvent(T event, long sequence, boolean endOfBatch) throws java.lang.Exception
Description copied from interface:EventHandler
Called when a publisher has published an event to theRingBuffer
. TheBatchEventProcessor
will read messages from theRingBuffer
in batches, where a batch is all of the events available to be processed without having to wait for any new event to arrive. This can be useful for event handlers that need to do slower operations like I/O as they can group together the data from multiple events into a single operation. Implementations should ensure that the operation is always performed when endOfBatch is true as the time between that message and the next one is indeterminate.- Specified by:
onEvent
in interfaceEventHandler<T>
- Parameters:
event
- published to theRingBuffer
sequence
- of the event being processedendOfBatch
- flag to indicate if this is the last event in a batch from theRingBuffer
- Throws:
java.lang.Exception
- if the EventHandler would like the exception handled further up the chain.
-
onStart
public void onStart()
-
onShutdown
public void onShutdown()
-
onBatchStart
public default void onBatchStart(long batchSize, long queueDepth)
Invoked byBatchEventProcessor
prior to processing a batch of events- Parameters:
batchSize
- the size of the batch that is startingqueueDepth
- the total number of queued up events including the batch about to be processed
-
onTimeout
public default void onTimeout(long sequence) throws java.lang.Exception
- Parameters:
sequence
- - the last processed sequence.- Throws:
java.lang.Exception
- if the implementation is unable to handle this timeout.
-
-