org.apache.hadoop.yarn.event
Class AsyncDispatcher

java.lang.Object
  extended by org.apache.hadoop.service.AbstractService
      extended by org.apache.hadoop.yarn.event.AsyncDispatcher
All Implemented Interfaces:
Closeable, Service, Dispatcher

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class AsyncDispatcher
extends AbstractService
implements Dispatcher

Dispatches Events 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.


Field Summary
protected  Map<Class<? extends Enum>,EventHandler> eventDispatchers
           
 
Fields inherited from interface org.apache.hadoop.yarn.event.Dispatcher
DEFAULT_DISPATCHER_EXIT_ON_ERROR, DISPATCHER_EXIT_ON_ERROR_KEY
 
Constructor Summary
AsyncDispatcher()
           
AsyncDispatcher(BlockingQueue<Event> eventQueue)
           
 
Method Summary
protected  void dispatch(Event event)
           
 EventHandler getEventHandler()
           
 void register(Class<? extends Enum> eventType, EventHandler handler)
           
protected  void serviceInit(Configuration conf)
          All initialization code needed by a service.
protected  void serviceStart()
          Actions called during the INITED to STARTED transition.
protected  void serviceStop()
          Actions called during the transition to the STOPPED state.
 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 Detail

eventDispatchers

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

AsyncDispatcher

public AsyncDispatcher()

AsyncDispatcher

public AsyncDispatcher(BlockingQueue<Event> eventQueue)
Method Detail

serviceInit

protected void serviceInit(Configuration conf)
                    throws Exception
Description copied from class: AbstractService
All initialization code needed by a service. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic in AbstractService.init(Configuration) prevents re-entrancy. The base implementation checks to see if the subclass has created a new configuration instance, and if so, updates the base class value

Overrides:
serviceInit in class AbstractService
Parameters:
conf - configuration
Throws:
Exception - on a failure -these will be caught, possibly wrapped, and wil; trigger a service stop

serviceStart

protected void serviceStart()
                     throws Exception
Description copied from class: AbstractService
Actions called during the INITED to STARTED transition. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic in AbstractService.start() prevents re-entrancy.

Overrides:
serviceStart in class AbstractService
Throws:
Exception - if needed -these will be caught, wrapped, and trigger a service stop

setDrainEventsOnStop

public void setDrainEventsOnStop()

serviceStop

protected void serviceStop()
                    throws Exception
Description copied from class: AbstractService
Actions called during the transition to the STOPPED state. This method will only ever be called once during the lifecycle of a specific service instance. Implementations do not need to be synchronized as the logic in AbstractService.stop() prevents re-entrancy. Implementations MUST write this to be robust against failures, including checks for null references -and for the first failure to not stop other attempts to shut down parts of the service.

Overrides:
serviceStop in class AbstractService
Throws:
Exception - if needed -these will be caught and logged.

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 getEventHandler()
Specified by:
getEventHandler in interface Dispatcher


Copyright © 2014 Apache Software Foundation. All Rights Reserved.