YARN=5526. DrainDispacher#serviceStop blocked if setDrainEventsOnStop invoked (sandflee via Varun Saxena)

This commit is contained in:
Varun Saxena 2016-08-18 11:38:13 +05:30
parent 20f0eb871c
commit 913a895136
2 changed files with 10 additions and 1 deletions

View File

@ -148,7 +148,7 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher {
YarnConfiguration.DEFAULT_DISPATCHER_DRAIN_EVENTS_TIMEOUT); YarnConfiguration.DEFAULT_DISPATCHER_DRAIN_EVENTS_TIMEOUT);
synchronized (waitForDrained) { synchronized (waitForDrained) {
while (!drained && eventHandlingThread != null while (!isDrained() && eventHandlingThread != null
&& eventHandlingThread.isAlive() && eventHandlingThread.isAlive()
&& System.currentTimeMillis() < endTime) { && System.currentTimeMillis() < endTime) {
waitForDrained.wait(1000); waitForDrained.wait(1000);
@ -303,4 +303,8 @@ public class AsyncDispatcher extends AbstractService implements Dispatcher {
protected boolean isEventThreadWaiting() { protected boolean isEventThreadWaiting() {
return eventHandlingThread.getState() == Thread.State.WAITING; return eventHandlingThread.getState() == Thread.State.WAITING;
} }
protected boolean isDrained() {
return drained;
}
} }

View File

@ -94,6 +94,11 @@ public class DrainDispatcher extends AsyncDispatcher {
}; };
} }
@Override
protected boolean isDrained() {
return drained;
}
@Override @Override
protected void serviceStop() throws Exception { protected void serviceStop() throws Exception {
stopped = true; stopped = true;