Class EventDispatcher<T extends Event>

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.event.EventDispatcher<T>
Type Parameters:
T - Type of Event
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service, EventHandler<T>

public class EventDispatcher<T extends Event> extends org.apache.hadoop.service.AbstractService implements EventHandler<T>
This is a specialized EventHandler to be used by Services that are expected handle a large number of events efficiently by ensuring that the caller thread is not blocked. Events are immediately stored in a BlockingQueue and a separate dedicated Thread consumes events from the queue and handles appropriately
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service

    org.apache.hadoop.service.Service.STATE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected long
     
    int
     
    void
    handle(T event)
     
    protected boolean
     
    protected void
     
    protected void
     
    void
     

    Methods inherited from class org.apache.hadoop.service.AbstractService

    close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceInit, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • serviceStart

      protected void serviceStart() throws Exception
      Overrides:
      serviceStart in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • serviceStop

      protected void serviceStop() throws Exception
      Overrides:
      serviceStop in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • handle

      public void handle(T event)
      Specified by:
      handle in interface EventHandler<T extends Event>
    • disableExitOnError

      @VisibleForTesting public void disableExitOnError()
    • setMetrics

      public void setMetrics(EventTypeMetrics metrics)
    • getEventProcessorId

      protected long getEventProcessorId()
    • isStopped

      protected boolean isStopped()
    • getEventQueueSize

      public int getEventQueueSize()