AMRMProxyService extends CompositeService implements
    ApplicationMasterProtocol { @Override public FinishApplicationMasterResponse finishApplicationMaster( FinishApplicationMasterRequest request) throws YarnException, IOException { long startTime = clock.getTime(); try { RequestInterceptorChainWrapper pipeline = authorizeAndGetInterceptorChain(); LOG.info("Finishing application master for {}. Tracking Url: {}", pipeline.getApplicationAttemptId(), request.getTrackingUrl()); FinishApplicationMasterResponse response = pipeline.getRootInterceptor().finishApplicationMaster(request); long endTime = clock.getTime(); this.metrics.succeededFinishAMRequests(endTime - startTime); LOG.info("FinishAM finished with isUnregistered = {} in {} ms for {}", response.getIsUnregistered(), endTime - startTime, pipeline.getApplicationAttemptId()); return response; } catch (Throwable t) { this.metrics.incrFailedFinishAMRequests(); throw t; } } AMRMProxyService(Context nmContext, AsyncDispatcher dispatcher); void recover(); @Override RegisterApplicationMasterResponse registerApplicationMaster(
      RegisterApplicationMasterRequest request); @Override FinishApplicationMasterResponse finishApplicationMaster(
      FinishApplicationMasterRequest request); @Override AllocateResponse allocate(AllocateRequest request); void processApplicationStartRequest(StartContainerRequest request); @Private InetSocketAddress getBindAddress(); @Private AMRMProxyTokenSecretManager getSecretManager();  }
@Test public void testFinishInvalidApplicationMaster() throws Exception { try { finishApplicationMaster(4, FinalApplicationStatus.SUCCEEDED); Assert .fail("The request to finish application master should have failed"); } catch (Throwable ex) { LOG.info("Finish registration failed as expected because it was not registered"); } }