@Test (timeout = 30000) public void testCancelWithMultipleAppSubmissions() throws Exception{ MockRM rm = new TestSecurityMockRM(conf, null); rm.start(); final MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService()); nm1.registerNode(); Text userText1 = new Text("user"); DelegationTokenIdentifier dtId1 = new DelegationTokenIdentifier(userText1, new Text("renewer1"), userText1); final Token<DelegationTokenIdentifier> token1 = new Token<DelegationTokenIdentifier>(dtId1.getBytes(), "password1".getBytes(), dtId1.getKind(), new Text("service1")); Credentials credentials = new Credentials(); credentials.addToken(token1.getService(), token1); DelegationTokenRenewer renewer = rm.getRMContext().getDelegationTokenRenewer(); Assert.assertTrue(renewer.getAllTokens().isEmpty()); Assert.assertFalse(Renewer.cancelled); RMApp app1 = rm.submitApp(200, "name", "user", null, false, null, 2, credentials, null, true, false, false, null, 0, null, true); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm, nm1); rm.waitForState(app1.getApplicationId(), RMAppState.RUNNING); DelegationTokenToRenew dttr = renewer.getAllTokens().get(token1); Assert.assertNotNull(dttr); Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId())); RMApp app2 = rm.submitApp(200, "name", "user", null, false, null, 2, credentials, null, true, false, false, null, 0, null, true); MockAM am2 = MockRM.launchAndRegisterAM(app2, rm, nm1); rm.waitForState(app2.getApplicationId(), RMAppState.RUNNING); Assert.assertTrue(renewer.getAllTokens().containsKey(token1)); Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId())); Assert.assertTrue(dttr.referringAppIds.contains(app2.getApplicationId())); Assert.assertFalse(Renewer.cancelled); MockRM.finishAMAndVerifyAppState(app2, rm, nm1, am2); Assert.assertTrue(renewer.getAllTokens().containsKey(token1)); Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId())); Assert.assertFalse(dttr.referringAppIds.contains(app2.getApplicationId())); Assert.assertFalse(dttr.isTimerCancelled()); Assert.assertFalse(Renewer.cancelled); RMApp app3 = rm.submitApp(200, "name", "user", null, false, null, 2, credentials, null, true, false, false, null, 0, null, true); MockAM am3 = MockRM.launchAndRegisterAM(app3, rm, nm1); rm.waitForState(app3.getApplicationId(), RMAppState.RUNNING); Assert.assertTrue(renewer.getAllTokens().containsKey(token1)); Assert.assertTrue(dttr.referringAppIds.contains(app1.getApplicationId())); Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId())); Assert.assertFalse(dttr.isTimerCancelled()); Assert.assertFalse(Renewer.cancelled); MockRM.finishAMAndVerifyAppState(app1, rm, nm1, am1); Assert.assertTrue(renewer.getAllTokens().containsKey(token1)); Assert.assertFalse(dttr.referringAppIds.contains(app1.getApplicationId())); Assert.assertTrue(dttr.referringAppIds.contains(app3.getApplicationId())); Assert.assertFalse(dttr.isTimerCancelled()); Assert.assertFalse(Renewer.cancelled); MockRM.finishAMAndVerifyAppState(app3, rm, nm1, am3); Assert.assertFalse(renewer.getAllTokens().containsKey(token1)); Assert.assertTrue(dttr.referringAppIds.isEmpty()); Assert.assertTrue(dttr.isTimerCancelled()); Assert.assertTrue(Renewer.cancelled); }
protected ConcurrentMap<Token<?>, DelegationTokenToRenew> getAllTokens() { return allTokens; }
DelegationTokenRenewer extends AbstractService { protected ConcurrentMap<Token<?>, DelegationTokenToRenew> getAllTokens() { return allTokens; } }
DelegationTokenRenewer extends AbstractService { protected ConcurrentMap<Token<?>, DelegationTokenToRenew> getAllTokens() { return allTokens; } DelegationTokenRenewer(); }
DelegationTokenRenewer extends AbstractService { protected ConcurrentMap<Token<?>, DelegationTokenToRenew> getAllTokens() { return allTokens; } DelegationTokenRenewer(); @VisibleForTesting Set<Token<?>> getDelegationTokens(); void addApplicationAsync(ApplicationId applicationId, Credentials ts,
      boolean shouldCancelAtEnd, String user); void addApplicationAsyncDuringRecovery(ApplicationId applicationId,
      Credentials ts, boolean shouldCancelAtEnd, String user); void addApplicationSync(ApplicationId applicationId, Credentials ts,
      boolean shouldCancelAtEnd, String user); void applicationFinished(ApplicationId applicationId); void updateKeepAliveApplications(List<ApplicationId> appIds); void setRMContext(RMContext rmContext); }
DelegationTokenRenewer extends AbstractService { protected ConcurrentMap<Token<?>, DelegationTokenToRenew> getAllTokens() { return allTokens; } DelegationTokenRenewer(); @VisibleForTesting Set<Token<?>> getDelegationTokens(); void addApplicationAsync(ApplicationId applicationId, Credentials ts,
      boolean shouldCancelAtEnd, String user); void addApplicationAsyncDuringRecovery(ApplicationId applicationId,
      Credentials ts, boolean shouldCancelAtEnd, String user); void addApplicationSync(ApplicationId applicationId, Credentials ts,
      boolean shouldCancelAtEnd, String user); void applicationFinished(ApplicationId applicationId); void updateKeepAliveApplications(List<ApplicationId> appIds); void setRMContext(RMContext rmContext); static final String SCHEME; static final String RM_SYSTEM_CREDENTIALS_VALID_TIME_REMAINING; static final long DEFAULT_RM_SYSTEM_CREDENTIALS_VALID_TIME_REMAINING; }