YARN-6015. AsyncDispatcher thread name can be set to improved debugging. Contributed by Ajith S.

This commit is contained in:
Naganarasimha 2017-01-07 08:11:58 +05:30
parent 020316458d
commit a59df15757
9 changed files with 23 additions and 9 deletions

View File

@ -74,6 +74,11 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher {
protected final Map<Class<? extends Enum>, EventHandler> eventDispatchers;
private boolean exitOnDispatchException;
/**
* The thread name for dispatcher.
*/
private String dispatcherThreadName = "AsyncDispatcher event handler";
public AsyncDispatcher() {
this(new LinkedBlockingQueue<Event>());
}
@ -84,6 +89,15 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher {
this.eventDispatchers = new HashMap<Class<? extends Enum>, EventHandler>();
}
/**
* Set a name for this dispatcher thread.
* @param dispatcherName name of the dispatcher thread
*/
public AsyncDispatcher(String dispatcherName) {
this();
dispatcherThreadName = dispatcherName;
}
Runnable createThread() {
return new Runnable() {
@Override
@ -130,7 +144,7 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher {
//start all the components
super.serviceStart();
eventHandlingThread = new Thread(createThread());
eventHandlingThread.setName("AsyncDispatcher event handler");
eventHandlingThread.setName(dispatcherThreadName);
eventHandlingThread.start();
}

View File

@ -211,7 +211,7 @@ public class CommonNodeLabelsManager extends AbstractService {
// for UT purpose
protected void initDispatcher(Configuration conf) {
// create async handler
dispatcher = new AsyncDispatcher();
dispatcher = new AsyncDispatcher("NodeLabelManager dispatcher");
AsyncDispatcher asyncDispatcher = (AsyncDispatcher) dispatcher;
asyncDispatcher.init(conf);
asyncDispatcher.setDrainEventsOnStop();

View File

@ -319,7 +319,7 @@ public class NodeManager extends CompositeService
addService(del);
// NodeManager level dispatcher
this.dispatcher = new AsyncDispatcher();
this.dispatcher = new AsyncDispatcher("NM Event dispatcher");
dirsHandler = new LocalDirsHandlerService(metrics);
nodeHealthChecker =

View File

@ -223,7 +223,7 @@ public class ContainerManagerImpl extends CompositeService implements
this.dirsHandler = dirsHandler;
// ContainerManager level dispatcher.
dispatcher = new AsyncDispatcher();
dispatcher = new AsyncDispatcher("NM ContainerManager dispatcher");
this.deletionService = deletionContext;
this.metrics = metrics;

View File

@ -86,7 +86,7 @@ public class NMTimelinePublisher extends CompositeService {
@Override
protected void serviceInit(Configuration conf) throws Exception {
dispatcher = new AsyncDispatcher();
dispatcher = new AsyncDispatcher("NM Timeline dispatcher");
dispatcher.register(NMTimelineEventType.class,
new ForwardingEventHandler());
addIfService(dispatcher);

View File

@ -414,7 +414,7 @@ public class ResourceManager extends CompositeService implements Recoverable {
}
protected Dispatcher createDispatcher() {
return new AsyncDispatcher();
return new AsyncDispatcher("RM Event dispatcher");
}
protected ResourceScheduler createScheduler() {

View File

@ -355,7 +355,7 @@ public class RMApplicationHistoryWriter extends CompositeService {
}
protected AsyncDispatcher createDispatcher() {
return new AsyncDispatcher();
return new AsyncDispatcher("RM ApplicationHistory dispatcher");
}
}

View File

@ -111,7 +111,7 @@ public abstract class AbstractSystemMetricsPublisher extends CompositeService
}
protected AsyncDispatcher createDispatcher() {
return new AsyncDispatcher();
return new AsyncDispatcher("RM Timeline dispatcher");
}
}

View File

@ -678,7 +678,7 @@ public abstract class RMStateStore extends AbstractService {
@Override
protected void serviceInit(Configuration conf) throws Exception{
// create async handler
dispatcher = new AsyncDispatcher();
dispatcher = new AsyncDispatcher("RM StateStore dispatcher");
dispatcher.init(conf);
rmStateStoreEventHandler = new ForwardingEventHandler();
dispatcher.register(RMStateStoreEventType.class,