AsyncDispatcher (Apache Hadoop YARN Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.yarn.event, class: AsyncDispatcher

Package org.apache.hadoop.yarn.event

# Class AsyncDispatcher

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.event.AsyncDispatcher

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`, `org.apache.hadoop.service.Service`, `Dispatcher`

@Public @Evolving public class AsyncDispatcher extends org.apache.hadoop.service.AbstractService implements Dispatcher
Dispatches `Event`s in a separate thread. Currently only single thread does that. Potentially there could be multiple channels for each event type class and a thread pool can be used to dispatch the events.

- ## Nested Class Summary

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

  `org.apache.hadoop.service.Service.STATE`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final Map<Class<? extends Enum>,EventHandler>`
  `eventDispatchers`
  `protected static final org.slf4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AsyncDispatcher()`
  `AsyncDispatcher(String dispatcherName)`
  Set a name for this dispatcher thread.
  `AsyncDispatcher(BlockingQueue<Event> eventQueue)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addMetrics(EventTypeMetrics metrics, Class<? extends Enum> eventClass)`
  `void`
  `disableExitOnDispatchException()`
  `protected void`
  `dispatch(Event event)`
  `EventHandler<Event>`
  `getEventHandler()`
  `int`
  `getEventQueueSize()`
  `protected boolean`
  `isDrained()`
  `protected boolean`
  `isEventThreadWaiting()`
  `protected boolean`
  `isStopped()`
  `protected void`
  `logTriggered(String message)`
  `void`
  `register(Class<? extends Enum> eventType, EventHandler handler)`
  `protected void`
  `serviceInit(org.apache.hadoop.conf.Configuration conf)`
  `protected void`
  `serviceStart()`
  `protected void`
  `serviceStop()`
  `void`
  `setDrainEventsOnStop()`

  ### 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, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### LOG

    protected static final org.slf4j.Logger LOG

  - ### eventDispatchers

    protected final Map<Class<? extends Enum>,EventHandler> eventDispatchers

- ## Constructor Details

  - ### AsyncDispatcher

    public AsyncDispatcher()

  - ### AsyncDispatcher

    public AsyncDispatcher(BlockingQueue<Event> eventQueue)

  - ### AsyncDispatcher

    public AsyncDispatcher(String dispatcherName)
    Set a name for this dispatcher thread.
    Parameters:
      `dispatcherName` - name of the dispatcher thread

- ## Method Details

  - ### logTriggered

    protected void logTriggered(String message)

  - ### disableExitOnDispatchException

    @VisibleForTesting public void disableExitOnDispatchException()

  - ### serviceInit

    protected void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
    Overrides:
      `serviceInit` in class `org.apache.hadoop.service.AbstractService`
    Throws:
      `Exception`

  - ### serviceStart

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

  - ### setDrainEventsOnStop

    public void setDrainEventsOnStop()

  - ### serviceStop

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

  - ### dispatch

    protected void dispatch(Event event)

  - ### register

    public void register(Class<? extends Enum> eventType, EventHandler handler)
    Specified by:
      `register` in interface `Dispatcher`

  - ### getEventHandler

    public EventHandler<Event> getEventHandler()
    Specified by:
      `getEventHandler` in interface `Dispatcher`

  - ### isEventThreadWaiting

    @VisibleForTesting protected boolean isEventThreadWaiting()

  - ### isDrained

    protected boolean isDrained()

  - ### isStopped

    protected boolean isStopped()

  - ### addMetrics

    public void addMetrics(EventTypeMetrics metrics, Class<? extends Enum> eventClass)

  - ### getEventQueueSize

    public int getEventQueueSize()