Class MonitorBatchEventProcessor<T>

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

    public final class MonitorBatchEventProcessor<T>
    extends java.lang.Object
    implements com.lmax.disruptor.EventProcessor
    This is a modification of BatchEventProcessor that reports monitor connection loss events.

    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 Summary

      Constructors 
      Constructor Description
      MonitorBatchEventProcessor​(ConnectionInterruptable channel, T disconnectedValue, java.util.function.Predicate<T> isDisconnectedValue, com.lmax.disruptor.DataProvider<T> dataProvider, com.lmax.disruptor.SequenceBarrier sequenceBarrier, com.lmax.disruptor.EventHandler<? super T> eventHandler)
      Construct a EventProcessor that will automatically track the progress by updating its sequence when the EventHandler.onEvent(Object, long, boolean) method returns.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.lmax.disruptor.Sequence getSequence()  
      void halt()  
      boolean isRunning()  
      void run()
      It is ok to have another thread rerun this method after a halt().
      void setExceptionHandler​(com.lmax.disruptor.ExceptionHandler<? super T> exceptionHandler)
      Set a new ExceptionHandler for handling exceptions propagated out of the MonitorBatchEventProcessor
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MonitorBatchEventProcessor

        public MonitorBatchEventProcessor​(ConnectionInterruptable channel,
                                          T disconnectedValue,
                                          java.util.function.Predicate<T> isDisconnectedValue,
                                          com.lmax.disruptor.DataProvider<T> dataProvider,
                                          com.lmax.disruptor.SequenceBarrier sequenceBarrier,
                                          com.lmax.disruptor.EventHandler<? super T> eventHandler)
        Construct a EventProcessor that will automatically track the progress by updating its sequence when the EventHandler.onEvent(Object, long, boolean) method returns.
        Parameters:
        channel - reference to an object which can report on the state of the connection.
        disconnectedValue - the value to be published to indicate channel disconnection.
        isDisconnectedValue - predicate which returns true when the channel is disconnected.
        dataProvider - to which events are published.
        sequenceBarrier - on which it is waiting.
        eventHandler - is the delegate to which events are dispatched.
    • Method Detail

      • getSequence

        public com.lmax.disruptor.Sequence getSequence()
        Specified by:
        getSequence in interface com.lmax.disruptor.EventProcessor
      • halt

        public void halt()
        Specified by:
        halt in interface com.lmax.disruptor.EventProcessor
      • isRunning

        public boolean isRunning()
        Specified by:
        isRunning in interface com.lmax.disruptor.EventProcessor
      • setExceptionHandler

        public void setExceptionHandler​(com.lmax.disruptor.ExceptionHandler<? super T> exceptionHandler)
        Set a new ExceptionHandler for handling exceptions propagated out of the MonitorBatchEventProcessor
        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