@Test(timeout=1200000) public void testFinishApplicationMasterBeforeRegistering() throws Exception { MockRM rm = new MockRM(conf); try { rm.start(); MockNM nm1 = rm.registerNode("127.0.0.1:1234", 6 * GB); RMApp app1 = rm.submitApp(2048); MockAM am1 = MockRM.launchAM(app1, rm, nm1); FinishApplicationMasterRequest req = FinishApplicationMasterRequest.newInstance( FinalApplicationStatus.FAILED, "", ""); Throwable cause = null; try { am1.unregisterAppAttempt(req, false); } catch (Exception e) { cause = e.getCause(); } Assert.assertNotNull(cause); Assert .assertTrue(cause instanceof ApplicationMasterNotRegisteredException); Assert.assertNotNull(cause.getMessage()); Assert .assertTrue(cause .getMessage() .contains( "Application Master is trying to unregister before registering for:")); am1.registerAppAttempt(); am1.unregisterAppAttempt(req, false); } finally { if (rm != null) { rm.stop(); } } }
public void registerAppAttempt(ApplicationAttemptId attemptId) { AllocateResponse response = recordFactory.newRecordInstance(AllocateResponse.class); response.setResponseId(-1); LOG.info("Registering app attempt : " + attemptId); responseMap.put(attemptId, new AllocateResponseLock(response)); rmContext.getNMTokenSecretManager().registerApplicationAttempt(attemptId); }
ApplicationMasterService extends AbstractService implements
    ApplicationMasterProtocol { public void registerAppAttempt(ApplicationAttemptId attemptId) { AllocateResponse response = recordFactory.newRecordInstance(AllocateResponse.class); response.setResponseId(-1); LOG.info("Registering app attempt : " + attemptId); responseMap.put(attemptId, new AllocateResponseLock(response)); rmContext.getNMTokenSecretManager().registerApplicationAttempt(attemptId); } }
ApplicationMasterService extends AbstractService implements
    ApplicationMasterProtocol { public void registerAppAttempt(ApplicationAttemptId attemptId) { AllocateResponse response = recordFactory.newRecordInstance(AllocateResponse.class); response.setResponseId(-1); LOG.info("Registering app attempt : " + attemptId); responseMap.put(attemptId, new AllocateResponseLock(response)); rmContext.getNMTokenSecretManager().registerApplicationAttempt(attemptId); } ApplicationMasterService(RMContext rmContext, YarnScheduler scheduler); }
ApplicationMasterService extends AbstractService implements
    ApplicationMasterProtocol { public void registerAppAttempt(ApplicationAttemptId attemptId) { AllocateResponse response = recordFactory.newRecordInstance(AllocateResponse.class); response.setResponseId(-1); LOG.info("Registering app attempt : " + attemptId); responseMap.put(attemptId, new AllocateResponseLock(response)); rmContext.getNMTokenSecretManager().registerApplicationAttempt(attemptId); } ApplicationMasterService(RMContext rmContext, YarnScheduler scheduler); @Private InetSocketAddress getBindAddress(); @Override RegisterApplicationMasterResponse registerApplicationMaster(
      RegisterApplicationMasterRequest request); @Override FinishApplicationMasterResponse finishApplicationMaster(
      FinishApplicationMasterRequest request); boolean hasApplicationMasterRegistered(
      ApplicationAttemptId appAttemptId); @Override AllocateResponse allocate(AllocateRequest request); void registerAppAttempt(ApplicationAttemptId attemptId); void unregisterAttempt(ApplicationAttemptId attemptId); void refreshServiceAcls(Configuration configuration, 
      PolicyProvider policyProvider); @VisibleForTesting Server getServer(); }
ApplicationMasterService extends AbstractService implements
    ApplicationMasterProtocol { public void registerAppAttempt(ApplicationAttemptId attemptId) { AllocateResponse response = recordFactory.newRecordInstance(AllocateResponse.class); response.setResponseId(-1); LOG.info("Registering app attempt : " + attemptId); responseMap.put(attemptId, new AllocateResponseLock(response)); rmContext.getNMTokenSecretManager().registerApplicationAttempt(attemptId); } ApplicationMasterService(RMContext rmContext, YarnScheduler scheduler); @Private InetSocketAddress getBindAddress(); @Override RegisterApplicationMasterResponse registerApplicationMaster(
      RegisterApplicationMasterRequest request); @Override FinishApplicationMasterResponse finishApplicationMaster(
      FinishApplicationMasterRequest request); boolean hasApplicationMasterRegistered(
      ApplicationAttemptId appAttemptId); @Override AllocateResponse allocate(AllocateRequest request); void registerAppAttempt(ApplicationAttemptId attemptId); void unregisterAttempt(ApplicationAttemptId attemptId); void refreshServiceAcls(Configuration configuration, 
      PolicyProvider policyProvider); @VisibleForTesting Server getServer();  }