YARN-1189. NMTokenSecretManagerInNM is not being told when applications have finished. Contributed by Omkar Vinit Joshi

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1523158 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason Darrell Lowe 2013-09-14 00:18:29 +00:00
parent 597c57ba2a
commit baea09be61
3 changed files with 31 additions and 0 deletions

View File

@ -197,6 +197,9 @@ Release 2.1.1-beta - UNRELEASED
YARN-1116. Populate AMRMTokens back to AMRMTokenSecretManager after RM YARN-1116. Populate AMRMTokens back to AMRMTokenSecretManager after RM
restarts (Jian He via bikas) restarts (Jian He via bikas)
YARN-1189. NMTokenSecretManagerInNM is not being told when applications
have finished (Omkar Vinit Joshi via jlowe)
Release 2.1.0-beta - 2013-08-22 Release 2.1.0-beta - 2013-08-22
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -395,6 +395,7 @@ public void transition(ApplicationImpl app, ApplicationEvent event) {
app.dispatcher.getEventHandler().handle( app.dispatcher.getEventHandler().handle(
new LogHandlerAppFinishedEvent(app.appId)); new LogHandlerAppFinishedEvent(app.appId));
app.context.getNMTokenSecretManager().appFinished(app.getAppId());
} }
} }

View File

@ -19,6 +19,7 @@
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.argThat; import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.refEq; import static org.mockito.Matchers.refEq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset;
@ -62,6 +63,7 @@
import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorEvent; import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorEvent;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorEventType; import org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorEventType;
import org.apache.hadoop.yarn.server.nodemanager.security.NMContainerTokenSecretManager; import org.apache.hadoop.yarn.server.nodemanager.security.NMContainerTokenSecretManager;
import org.apache.hadoop.yarn.server.nodemanager.security.NMTokenSecretManagerInNM;
import org.apache.hadoop.yarn.server.security.ApplicationACLsManager; import org.apache.hadoop.yarn.server.security.ApplicationACLsManager;
import org.apache.hadoop.yarn.server.utils.BuilderUtils; import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import org.junit.Test; import org.junit.Test;
@ -413,6 +415,27 @@ public void testAppFinishedOnIniting() {
} }
} }
@Test
public void testNMTokenSecretManagerCleanup() {
WrappedApplication wa = null;
try {
wa = new WrappedApplication(1, 314159265358979L, "yak", 1);
wa.initApplication();
wa.initContainer(0);
assertEquals(ApplicationState.INITING, wa.app.getApplicationState());
assertEquals(1, wa.app.getContainers().size());
wa.appFinished();
wa.containerFinished(0);
wa.appResourcesCleanedup();
assertEquals(ApplicationState.FINISHED, wa.app.getApplicationState());
verify(wa.nmTokenSecretMgr).appFinished(eq(wa.appId));
} finally {
if (wa != null) {
wa.finished();
}
}
}
private class ContainerKillMatcher extends ArgumentMatcher<ContainerEvent> { private class ContainerKillMatcher extends ArgumentMatcher<ContainerEvent> {
private ContainerId cId; private ContainerId cId;
@ -460,6 +483,7 @@ private class WrappedApplication {
final List<Container> containers; final List<Container> containers;
final Context context; final Context context;
final Map<ContainerId, ContainerTokenIdentifier> containerTokenIdentifierMap; final Map<ContainerId, ContainerTokenIdentifier> containerTokenIdentifierMap;
final NMTokenSecretManagerInNM nmTokenSecretMgr;
final ApplicationId appId; final ApplicationId appId;
final Application app; final Application app;
@ -486,12 +510,15 @@ private class WrappedApplication {
dispatcher.register(ContainerEventType.class, containerBus); dispatcher.register(ContainerEventType.class, containerBus);
dispatcher.register(LogHandlerEventType.class, logAggregationBus); dispatcher.register(LogHandlerEventType.class, logAggregationBus);
nmTokenSecretMgr = mock(NMTokenSecretManagerInNM.class);
context = mock(Context.class); context = mock(Context.class);
when(context.getContainerTokenSecretManager()).thenReturn( when(context.getContainerTokenSecretManager()).thenReturn(
new NMContainerTokenSecretManager(conf)); new NMContainerTokenSecretManager(conf));
when(context.getApplicationACLsManager()).thenReturn( when(context.getApplicationACLsManager()).thenReturn(
new ApplicationACLsManager(conf)); new ApplicationACLsManager(conf));
when(context.getNMTokenSecretManager()).thenReturn(nmTokenSecretMgr);
// Setting master key // Setting master key
MasterKey masterKey = new MasterKeyPBImpl(); MasterKey masterKey = new MasterKeyPBImpl();