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,Service,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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<Class<? extends Enum>,EventHandler> protected static final org.slf4j.Logger -
Constructor Summary
ConstructorsConstructorDescriptionAsyncDispatcher(String dispatcherName) Set a name for this dispatcher thread.AsyncDispatcher(BlockingQueue<Event> eventQueue) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMetrics(org.apache.hadoop.yarn.metrics.EventTypeMetrics metrics, Class<? extends Enum> eventClass) voidprotected voidintprotected booleanprotected booleanprotected booleanprotected voidlogTriggered(String message) voidregister(Class<? extends Enum> eventType, EventHandler handler) protected voidserviceInit(Configuration conf) All initialization code needed by a service.protected voidActions called during the INITED to STARTED transition.protected voidActions called during the transition to the STOPPED state.voidMethods 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
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG -
eventDispatchers
-
-
Constructor Details
-
AsyncDispatcher
public AsyncDispatcher() -
AsyncDispatcher
-
AsyncDispatcher
Set a name for this dispatcher thread.- Parameters:
dispatcherName- name of the dispatcher thread
-
-
Method Details
-
logTriggered
-
disableExitOnDispatchException
@VisibleForTesting public void disableExitOnDispatchException() -
serviceInit
Description copied from class:AbstractServiceAll 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 inAbstractService.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:
serviceInitin classAbstractService- Parameters:
conf- configuration- Throws:
Exception- on a failure -these will be caught, possibly wrapped, and will trigger a service stop
-
serviceStart
Description copied from class:AbstractServiceActions 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 inAbstractService.start()prevents re-entrancy.- Overrides:
serviceStartin classAbstractService- Throws:
Exception- if needed -these will be caught, wrapped, and trigger a service stop
-
setDrainEventsOnStop
public void setDrainEventsOnStop() -
serviceStop
Description copied from class:AbstractServiceActions 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 inAbstractService.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:
serviceStopin classAbstractService- Throws:
Exception- if needed -these will be caught and logged.
-
dispatch
-
register
- Specified by:
registerin interfaceDispatcher
-
getEventHandler
- Specified by:
getEventHandlerin interfaceDispatcher
-
isEventThreadWaiting
@VisibleForTesting protected boolean isEventThreadWaiting() -
isDrained
protected boolean isDrained() -
isStopped
protected boolean isStopped() -
addMetrics
-
getEventQueueSize
public int getEventQueueSize()
-