YARN-42. Modify NM's non-aggregating logs' handler to stop properly so that NMs don't get NPEs on startup errors. Contributed by Devaraj K.
svn merge --ignore-ancestry -c 1380954 ../../trunk/ git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1380955 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb78183b2b
commit
dad420c609
|
@ -59,6 +59,9 @@ Release 2.1.0-alpha - Unreleased
|
||||||
YARN-79. Implement close on all clients to YARN so that RPC clients don't
|
YARN-79. Implement close on all clients to YARN so that RPC clients don't
|
||||||
throw exceptions on shut-down. (Vinod Kumar Vavilapalli)
|
throw exceptions on shut-down. (Vinod Kumar Vavilapalli)
|
||||||
|
|
||||||
|
YARN-42. Modify NM's non-aggregating logs' handler to stop properly so that
|
||||||
|
NMs don't get NPEs on startup errors. (Devaraj K via vinodkv)
|
||||||
|
|
||||||
Release 0.23.4 - UNRELEASED
|
Release 0.23.4 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -79,16 +79,18 @@ public class NonAggregatingLogHandler extends AbstractService implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
sched.shutdown();
|
if (sched != null) {
|
||||||
boolean isShutdown = false;
|
sched.shutdown();
|
||||||
try {
|
boolean isShutdown = false;
|
||||||
isShutdown = sched.awaitTermination(10, TimeUnit.SECONDS);
|
try {
|
||||||
} catch (InterruptedException e) {
|
isShutdown = sched.awaitTermination(10, TimeUnit.SECONDS);
|
||||||
sched.shutdownNow();
|
} catch (InterruptedException e) {
|
||||||
isShutdown = true;
|
sched.shutdownNow();
|
||||||
}
|
isShutdown = true;
|
||||||
if (!isShutdown) {
|
}
|
||||||
sched.shutdownNow();
|
if (!isShutdown) {
|
||||||
|
sched.shutdownNow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.stop();
|
super.stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,6 +184,24 @@ public class TestNonAggregatingLogHandler {
|
||||||
eq(TimeUnit.SECONDS));
|
eq(TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStop() throws Exception {
|
||||||
|
NonAggregatingLogHandler aggregatingLogHandler =
|
||||||
|
new NonAggregatingLogHandler(null, null, null);
|
||||||
|
|
||||||
|
// It should not throw NullPointerException
|
||||||
|
aggregatingLogHandler.stop();
|
||||||
|
|
||||||
|
NonAggregatingLogHandlerWithMockExecutor logHandler =
|
||||||
|
new NonAggregatingLogHandlerWithMockExecutor(null, null, null);
|
||||||
|
logHandler.init(new Configuration());
|
||||||
|
logHandler.stop();
|
||||||
|
verify(logHandler.mockSched).shutdown();
|
||||||
|
verify(logHandler.mockSched)
|
||||||
|
.awaitTermination(eq(10l), eq(TimeUnit.SECONDS));
|
||||||
|
verify(logHandler.mockSched).shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
private class NonAggregatingLogHandlerWithMockExecutor extends
|
private class NonAggregatingLogHandlerWithMockExecutor extends
|
||||||
NonAggregatingLogHandler {
|
NonAggregatingLogHandler {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue