From ea38256fab9f6986dc0092b72413a0d7626b498f Mon Sep 17 00:00:00 2001 From: Naganarasimha Date: Tue, 10 Jan 2017 15:10:54 +0530 Subject: [PATCH] YARN-6015. AsyncDispatcher thread name can be set to improved debugging. Contributed by Ajith S. --- .../hadoop/yarn/event/AsyncDispatcher.java | 16 +++++++++++++++- .../yarn/nodelabels/CommonNodeLabelsManager.java | 2 +- .../yarn/server/nodemanager/NodeManager.java | 2 +- .../containermanager/ContainerManagerImpl.java | 2 +- .../server/resourcemanager/ResourceManager.java | 2 +- .../ahs/RMApplicationHistoryWriter.java | 2 +- .../metrics/SystemMetricsPublisher.java | 2 +- .../resourcemanager/recovery/RMStateStore.java | 2 +- 8 files changed, 22 insertions(+), 8 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java index 94bfab61ee4..ff472bf1580 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/event/AsyncDispatcher.java @@ -74,6 +74,11 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher { protected final Map, EventHandler> eventDispatchers; private boolean exitOnDispatchException; + /** + * The thread name for dispatcher. + */ + private String dispatcherThreadName = "AsyncDispatcher event handler"; + public AsyncDispatcher() { this(new LinkedBlockingQueue()); } @@ -84,6 +89,15 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher { this.eventDispatchers = new HashMap, 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(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java index 1a83632c4e4..f3f4ba0ff90 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java @@ -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(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java index dced31bb47c..3c768a53270 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java @@ -311,7 +311,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 = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java index 9d5246f15e6..391cf5f7702 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java @@ -218,7 +218,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; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index 76b39770759..edc8da8cc6c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -388,7 +388,7 @@ public class ResourceManager extends CompositeService implements Recoverable { } protected Dispatcher createDispatcher() { - return new AsyncDispatcher(); + return new AsyncDispatcher("RM Event dispatcher"); } protected ResourceScheduler createScheduler() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java index bd328abe7cc..940088f8bd1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/RMApplicationHistoryWriter.java @@ -355,7 +355,7 @@ public class RMApplicationHistoryWriter extends CompositeService { } protected AsyncDispatcher createDispatcher() { - return new AsyncDispatcher(); + return new AsyncDispatcher("RM ApplicationHistory dispatcher"); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java index 775e6e3966b..3382509d615 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/SystemMetricsPublisher.java @@ -634,7 +634,7 @@ public class SystemMetricsPublisher extends CompositeService { } protected AsyncDispatcher createDispatcher() { - return new AsyncDispatcher(); + return new AsyncDispatcher("RM Timeline dispatcher"); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java index 0fd346f0ddd..6ede3b4a17b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/RMStateStore.java @@ -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,