Class BatchEventProcessor<T>

  • Type Parameters:
    T - event implementation storing the data for sharing during exchange or parallel coordination of an event.
    All Implemented Interfaces:
    EventProcessor, java.lang.Runnable

    public final class BatchEventProcessor<T>
    extends java.lang.Object
    implements EventProcessor
    Convenience class for handling the batching semantics of consuming entries from a RingBuffer and delegating the available events to an EventHandler.

    If the EventHandler also implements LifecycleAware it will be notified just after the thread is started and just before the thread is shutdown.

    • Constructor Detail

    • Method Detail

      • halt

        public void halt()
        Description copied from interface: EventProcessor
        Signal that this EventProcessor should stop when it has finished consuming at the next clean break. It will call SequenceBarrier.alert() to notify the thread to check status.
        Specified by:
        halt in interface EventProcessor
      • setExceptionHandler

        public void setExceptionHandler​(ExceptionHandler<? super T> exceptionHandler)
        Set a new ExceptionHandler for handling exceptions propagated out of the BatchEventProcessor
        Parameters:
        exceptionHandler - to replace the existing exceptionHandler.
      • run

        public void run()
        It is ok to have another thread rerun this method after a halt().
        Specified by:
        run in interface java.lang.Runnable
        Throws:
        java.lang.IllegalStateException - if this object instance is already running in a thread
      • processEvents

        private void processEvents()
      • earlyExit

        private void earlyExit()
      • notifyTimeout

        private void notifyTimeout​(long availableSequence)
      • notifyStart

        private void notifyStart()
        Notifies the EventHandler when this processor is starting up
      • notifyShutdown

        private void notifyShutdown()
        Notifies the EventHandler immediately prior to this processor shutting down