From 5fa7a14da97872238fc17968835ad8c3c7af604a Mon Sep 17 00:00:00 2001 From: Varun Saxena Date: Thu, 18 Aug 2016 12:23:34 +0530 Subject: [PATCH] YARN=5526. DrainDispacher#serviceStop blocked if setDrainEventsOnStop invoked (sandflee via Varun Saxena) --- .../java/org/apache/hadoop/yarn/event/AsyncDispatcher.java | 6 +++++- .../java/org/apache/hadoop/yarn/event/DrainDispatcher.java | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 5dea1c83cfb..89b58614fb3 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 @@ -148,7 +148,7 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher { YarnConfiguration.DEFAULT_DISPATCHER_DRAIN_EVENTS_TIMEOUT); synchronized (waitForDrained) { - while (!drained && eventHandlingThread != null + while (!isDrained() && eventHandlingThread != null && eventHandlingThread.isAlive() && System.currentTimeMillis() < endTime) { waitForDrained.wait(1000); @@ -303,4 +303,8 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher { protected boolean isEventThreadWaiting() { return eventHandlingThread.getState() == Thread.State.WAITING; } + + protected boolean isDrained() { + return drained; + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/DrainDispatcher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/DrainDispatcher.java index cf4b1b54d17..f76949200f5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/DrainDispatcher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/event/DrainDispatcher.java @@ -94,6 +94,11 @@ public class DrainDispatcher extends AsyncDispatcher { }; } + @Override + protected boolean isDrained() { + return drained; + } + @Override protected void serviceStop() throws Exception { stopped = true;