Java 类org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterResponse 实例源码

项目:hadoop    文件:TestUnmanagedAMLauncher.java   
public static void main(String[] args) throws Exception {
  if (args[0].equals("success")) {
    ApplicationMasterProtocol client = ClientRMProxy.createRMProxy(conf,
        ApplicationMasterProtocol.class);
    client.registerApplicationMaster(RegisterApplicationMasterRequest
        .newInstance(NetUtils.getHostname(), -1, ""));
    Thread.sleep(1000);
    FinishApplicationMasterResponse resp =
        client.finishApplicationMaster(FinishApplicationMasterRequest
          .newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
    assertTrue(resp.getIsUnregistered());
    System.exit(0);
  } else {
    System.exit(1);
  }
}
项目:aliyun-oss-hadoop-fs    文件:MockResourceManagerFacade.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  String amrmToken = getAppIdentifier();
  Log.info("Finishing application attempt: " + amrmToken);

  synchronized (applicationContainerIdMap) {
    // Remove the containers that were being tracked for this application
    Assert.assertTrue("The application id is NOT registered: "
        + amrmToken, applicationContainerIdMap.containsKey(amrmToken));
    List<ContainerId> ids = applicationContainerIdMap.remove(amrmToken);
    for (ContainerId c : ids) {
      allocatedContainerMap.remove(c);
    }
  }

  return FinishApplicationMasterResponse
      .newInstance(request.getFinalApplicationStatus() == FinalApplicationStatus.SUCCEEDED ? true
          : false);
}
项目:aliyun-oss-hadoop-fs    文件:TestAMRMProxyService.java   
@Test
public void testFinishOneApplicationMasterWithSuccess() throws Exception {
  int testAppId = 1;
  RegisterApplicationMasterResponse registerResponse =
      registerApplicationMaster(testAppId);
  Assert.assertNotNull(registerResponse);
  Assert.assertEquals(Integer.toString(testAppId),
      registerResponse.getQueue());

  FinishApplicationMasterResponse finshResponse =
      finishApplicationMaster(testAppId,
          FinalApplicationStatus.SUCCEEDED);

  Assert.assertNotNull(finshResponse);
  Assert.assertEquals(true, finshResponse.getIsUnregistered());
}
项目:aliyun-oss-hadoop-fs    文件:TestAMRMProxyService.java   
@Test
public void testFinishOneApplicationMasterWithFailure() throws Exception {
  int testAppId = 1;
  RegisterApplicationMasterResponse registerResponse =
      registerApplicationMaster(testAppId);
  Assert.assertNotNull(registerResponse);
  Assert.assertEquals(Integer.toString(testAppId),
      registerResponse.getQueue());

  FinishApplicationMasterResponse finshResponse =
      finishApplicationMaster(testAppId, FinalApplicationStatus.FAILED);

  Assert.assertNotNull(finshResponse);
  Assert.assertEquals(false, finshResponse.getIsUnregistered());

  try {
    // Try to finish an application master that is already finished.
    finishApplicationMaster(testAppId, FinalApplicationStatus.SUCCEEDED);
    Assert
        .fail("The request to finish application master should have failed");
  } catch (Throwable ex) {
    // This is expected. So nothing required here.
    LOG.info("Finish registration failed as expected because it was not registered");
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestAMRMProxyService.java   
@Test
public void testAllocateRequestWithNullValues() throws Exception {
  int testAppId = 1;
  RegisterApplicationMasterResponse registerResponse =
      registerApplicationMaster(testAppId);
  Assert.assertNotNull(registerResponse);
  Assert.assertEquals(Integer.toString(testAppId),
      registerResponse.getQueue());

  AllocateResponse allocateResponse = allocate(testAppId);
  Assert.assertNotNull(allocateResponse);

  FinishApplicationMasterResponse finshResponse =
      finishApplicationMaster(testAppId,
          FinalApplicationStatus.SUCCEEDED);

  Assert.assertNotNull(finshResponse);
  Assert.assertEquals(true, finshResponse.getIsUnregistered());
}
项目:aliyun-oss-hadoop-fs    文件:TestUnmanagedAMLauncher.java   
public static void main(String[] args) throws Exception {
  if (args[0].equals("success")) {
    ApplicationMasterProtocol client = ClientRMProxy.createRMProxy(conf,
        ApplicationMasterProtocol.class);
    client.registerApplicationMaster(RegisterApplicationMasterRequest
        .newInstance(NetUtils.getHostname(), -1, ""));
    Thread.sleep(1000);
    FinishApplicationMasterResponse resp =
        client.finishApplicationMaster(FinishApplicationMasterRequest
          .newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
    assertTrue(resp.getIsUnregistered());
    System.exit(0);
  } else {
    System.exit(1);
  }
}
项目:big-c    文件:TestUnmanagedAMLauncher.java   
public static void main(String[] args) throws Exception {
  if (args[0].equals("success")) {
    ApplicationMasterProtocol client = ClientRMProxy.createRMProxy(conf,
        ApplicationMasterProtocol.class);
    client.registerApplicationMaster(RegisterApplicationMasterRequest
        .newInstance(NetUtils.getHostname(), -1, ""));
    Thread.sleep(1000);
    FinishApplicationMasterResponse resp =
        client.finishApplicationMaster(FinishApplicationMasterRequest
          .newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
    assertTrue(resp.getIsUnregistered());
    System.exit(0);
  } else {
    System.exit(1);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestUnmanagedAMLauncher.java   
public static void main(String[] args) throws Exception {
  if (args[0].equals("success")) {
    ApplicationMasterProtocol client = ClientRMProxy.createRMProxy(conf,
        ApplicationMasterProtocol.class);
    client.registerApplicationMaster(RegisterApplicationMasterRequest
        .newInstance(NetUtils.getHostname(), -1, ""));
    Thread.sleep(1000);
    FinishApplicationMasterResponse resp =
        client.finishApplicationMaster(FinishApplicationMasterRequest
          .newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
    assertTrue(resp.getIsUnregistered());
    System.exit(0);
  } else {
    System.exit(1);
  }
}
项目:hops    文件:MockResourceManagerFacade.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  String amrmToken = getAppIdentifier();
  Log.info("Finishing application attempt: " + amrmToken);

  synchronized (applicationContainerIdMap) {
    // Remove the containers that were being tracked for this application
    Assert.assertTrue("The application id is NOT registered: "
        + amrmToken, applicationContainerIdMap.containsKey(amrmToken));
    List<ContainerId> ids = applicationContainerIdMap.remove(amrmToken);
    for (ContainerId c : ids) {
      allocatedContainerMap.remove(c);
    }
  }

  return FinishApplicationMasterResponse
      .newInstance(request.getFinalApplicationStatus() == FinalApplicationStatus.SUCCEEDED ? true
          : false);
}
项目:hops    文件:TestAMRMProxyService.java   
@Test
public void testFinishOneApplicationMasterWithSuccess() throws Exception {
  int testAppId = 1;
  RegisterApplicationMasterResponse registerResponse =
      registerApplicationMaster(testAppId);
  Assert.assertNotNull(registerResponse);
  Assert.assertEquals(Integer.toString(testAppId),
      registerResponse.getQueue());

  FinishApplicationMasterResponse finshResponse =
      finishApplicationMaster(testAppId,
          FinalApplicationStatus.SUCCEEDED);

  Assert.assertNotNull(finshResponse);
  Assert.assertEquals(true, finshResponse.getIsUnregistered());
}
项目:hops    文件:TestAMRMProxyService.java   
@Test
public void testFinishOneApplicationMasterWithFailure() throws Exception {
  int testAppId = 1;
  RegisterApplicationMasterResponse registerResponse =
      registerApplicationMaster(testAppId);
  Assert.assertNotNull(registerResponse);
  Assert.assertEquals(Integer.toString(testAppId),
      registerResponse.getQueue());

  FinishApplicationMasterResponse finshResponse =
      finishApplicationMaster(testAppId, FinalApplicationStatus.FAILED);

  Assert.assertNotNull(finshResponse);
  Assert.assertEquals(false, finshResponse.getIsUnregistered());

  try {
    // Try to finish an application master that is already finished.
    finishApplicationMaster(testAppId, FinalApplicationStatus.SUCCEEDED);
    Assert
        .fail("The request to finish application master should have failed");
  } catch (Throwable ex) {
    // This is expected. So nothing required here.
    LOG.info("Finish registration failed as expected because it was not registered");
  }
}
项目:hops    文件:TestAMRMProxyService.java   
@Test
public void testAllocateRequestWithNullValues() throws Exception {
  int testAppId = 1;
  RegisterApplicationMasterResponse registerResponse =
      registerApplicationMaster(testAppId);
  Assert.assertNotNull(registerResponse);
  Assert.assertEquals(Integer.toString(testAppId),
      registerResponse.getQueue());

  AllocateResponse allocateResponse = allocate(testAppId);
  Assert.assertNotNull(allocateResponse);

  FinishApplicationMasterResponse finshResponse =
      finishApplicationMaster(testAppId,
          FinalApplicationStatus.SUCCEEDED);

  Assert.assertNotNull(finshResponse);
  Assert.assertEquals(true, finshResponse.getIsUnregistered());
}
项目:hops    文件:TestUnmanagedAMLauncher.java   
public static void main(String[] args) throws Exception {
  if (args[0].equals("success")) {
    ApplicationMasterProtocol client = ClientRMProxy.createRMProxy(conf,
        ApplicationMasterProtocol.class, true);
    client.registerApplicationMaster(RegisterApplicationMasterRequest
        .newInstance(NetUtils.getHostname(), -1, ""));
    Thread.sleep(1000);
    FinishApplicationMasterResponse resp =
        client.finishApplicationMaster(FinishApplicationMasterRequest
          .newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
    assertTrue(resp.getIsUnregistered());
    System.exit(0);
  } else {
    System.exit(1);
  }
}
项目:hadoop-TCP    文件:AMRMClientImpl.java   
@Override
public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
    String appMessage, String appTrackingUrl) throws YarnException,
    IOException {
  Preconditions.checkArgument(appStatus != null,
    "AppStatus should not be null.");
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(appStatus, appMessage,
        appTrackingUrl);
  try {
    while (true) {
      FinishApplicationMasterResponse response =
          rmClient.finishApplicationMaster(request);
      if (response.getIsUnregistered()) {
        break;
      }
      LOG.info("Waiting for application to be successfully unregistered.");
      Thread.sleep(100);
    }
  } catch (InterruptedException e) {
    LOG.info("Interrupted while waiting for application"
        + " to be removed from RMStateStore");
  }
}
项目:hardfs    文件:AMRMClientImpl.java   
@Override
public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
    String appMessage, String appTrackingUrl) throws YarnException,
    IOException {
  Preconditions.checkArgument(appStatus != null,
    "AppStatus should not be null.");
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(appStatus, appMessage,
        appTrackingUrl);
  try {
    while (true) {
      FinishApplicationMasterResponse response =
          rmClient.finishApplicationMaster(request);
      if (response.getIsUnregistered()) {
        break;
      }
      LOG.info("Waiting for application to be successfully unregistered.");
      Thread.sleep(100);
    }
  } catch (InterruptedException e) {
    LOG.info("Interrupted while waiting for application"
        + " to be removed from RMStateStore");
  }
}
项目:hadoop-on-lustre2    文件:AMRMClientImpl.java   
@Override
public void unregisterApplicationMaster(FinalApplicationStatus appStatus,
    String appMessage, String appTrackingUrl) throws YarnException,
    IOException {
  Preconditions.checkArgument(appStatus != null,
    "AppStatus should not be null.");
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(appStatus, appMessage,
        appTrackingUrl);
  try {
    while (true) {
      FinishApplicationMasterResponse response =
          rmClient.finishApplicationMaster(request);
      if (response.getIsUnregistered()) {
        break;
      }
      LOG.info("Waiting for application to be successfully unregistered.");
      Thread.sleep(100);
    }
  } catch (InterruptedException e) {
    LOG.info("Interrupted while waiting for application"
        + " to be removed from RMStateStore");
  }
}
项目:hadoop-on-lustre2    文件:TestUnmanagedAMLauncher.java   
public static void main(String[] args) throws Exception {
  if (args[0].equals("success")) {
    ApplicationMasterProtocol client = ClientRMProxy.createRMProxy(conf,
        ApplicationMasterProtocol.class);
    client.registerApplicationMaster(RegisterApplicationMasterRequest
        .newInstance(NetUtils.getHostname(), -1, ""));
    Thread.sleep(1000);
    FinishApplicationMasterResponse resp =
        client.finishApplicationMaster(FinishApplicationMasterRequest
          .newInstance(FinalApplicationStatus.SUCCEEDED, "success", null));
    assertTrue(resp.getIsUnregistered());
    System.exit(0);
  } else {
    System.exit(1);
  }
}
项目:hadoop    文件:ApplicationMasterProtocolPBClientImpl.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  FinishApplicationMasterRequestProto requestProto =
      ((FinishApplicationMasterRequestPBImpl) request).getProto();
  try {
    return new FinishApplicationMasterResponsePBImpl(
      proxy.finishApplicationMaster(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop    文件:TestRPCFactories.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  // TODO Auto-generated method stub
  return null;
}
项目:hadoop    文件:ProtocolHATestBase.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  resetStartFailoverFlag(true);
  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());
  return createFakeFinishApplicationMasterResponse();
}
项目:hadoop    文件:TestApplicationMasterServiceProtocolOnHA.java   
@Test(timeout = 15000)
public void testFinishApplicationMasterOnHA() throws YarnException,
    IOException {
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(
          FinalApplicationStatus.SUCCEEDED, "", "");
  FinishApplicationMasterResponse response =
      amClient.finishApplicationMaster(request);
  Assert.assertEquals(response,
      this.cluster.createFakeFinishApplicationMasterResponse());
}
项目:scheduling-connector-for-hadoop    文件:HPCApplicationMasterProtocolImpl.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException, IOException {
  ApplicationMasterFinishRequest finishRequest = new ApplicationMasterFinishRequest(
      request.getFinalApplicationStatus(), request.getDiagnostics(),
      request.getTrackingUrl());
  ApplicationMasterFinishResponse response = applicationMaster
      .finishApplicationMaster(finishRequest);
  return FinishApplicationMasterResponse.newInstance(response
      .isUnregistered());
}
项目:aliyun-oss-hadoop-fs    文件:ApplicationMasterProtocolPBClientImpl.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  FinishApplicationMasterRequestProto requestProto =
      ((FinishApplicationMasterRequestPBImpl) request).getProto();
  try {
    return new FinishApplicationMasterResponsePBImpl(
      proxy.finishApplicationMaster(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestRPCFactories.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  // TODO Auto-generated method stub
  return null;
}
项目:aliyun-oss-hadoop-fs    文件:AMRMProxyService.java   
/**
 * This is called by the AMs started on this node to unregister from the RM.
 * This method does the initial authorization and then forwards the request to
 * the application instance specific intercepter chain.
 */
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  LOG.info("Finishing application master. Tracking Url:"
      + request.getTrackingUrl());
  RequestInterceptorChainWrapper pipeline =
      authorizeAndGetInterceptorChain();
  return pipeline.getRootInterceptor().finishApplicationMaster(request);
}
项目:aliyun-oss-hadoop-fs    文件:DefaultRequestInterceptor.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    final FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  LOG.info("Forwarding finish application request to "
      + "the real YARN Resource Manager");
  return rmClient.finishApplicationMaster(request);
}
项目:aliyun-oss-hadoop-fs    文件:BaseAMRMProxyTest.java   
/**
 * Unregisters the application master for specified application id
 * 
 * @param appId
 * @param status
 * @return
 * @throws Exception
 * @throws YarnException
 * @throws IOException
 */
protected FinishApplicationMasterResponse finishApplicationMaster(
    final int appId, final FinalApplicationStatus status)
    throws Exception, YarnException, IOException {

  final ApplicationUserInfo ugi = getApplicationUserInfo(appId);

  return ugi.getUser().doAs(
      new PrivilegedExceptionAction<FinishApplicationMasterResponse>() {
        @Override
        public FinishApplicationMasterResponse run() throws Exception {
          final FinishApplicationMasterRequest req =
              Records.newRecord(FinishApplicationMasterRequest.class);
          req.setDiagnostics("");
          req.setTrackingUrl("");
          req.setFinalApplicationStatus(status);

          FinishApplicationMasterResponse response =
              getAMRMProxyService().finishApplicationMaster(req);

          getAMRMProxyService().stopApp(
              ugi.getAppAttemptId().getApplicationId());

          return response;
        }
      });
}
项目:aliyun-oss-hadoop-fs    文件:ProtocolHATestBase.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  resetStartFailoverFlag(true);
  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());
  return createFakeFinishApplicationMasterResponse();
}
项目:aliyun-oss-hadoop-fs    文件:TestApplicationMasterServiceProtocolOnHA.java   
@Test(timeout = 15000)
public void testFinishApplicationMasterOnHA() throws YarnException,
    IOException {
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(
          FinalApplicationStatus.SUCCEEDED, "", "");
  FinishApplicationMasterResponse response =
      amClient.finishApplicationMaster(request);
  Assert.assertEquals(response,
      this.cluster.createFakeFinishApplicationMasterResponse());
}
项目:big-c    文件:ApplicationMasterProtocolPBClientImpl.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  FinishApplicationMasterRequestProto requestProto =
      ((FinishApplicationMasterRequestPBImpl) request).getProto();
  try {
    return new FinishApplicationMasterResponsePBImpl(
      proxy.finishApplicationMaster(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:big-c    文件:TestRPCFactories.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  // TODO Auto-generated method stub
  return null;
}
项目:big-c    文件:ProtocolHATestBase.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  resetStartFailoverFlag(true);
  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());
  return createFakeFinishApplicationMasterResponse();
}
项目:big-c    文件:TestApplicationMasterServiceProtocolOnHA.java   
@Test(timeout = 15000)
public void testFinishApplicationMasterOnHA() throws YarnException,
    IOException {
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(
          FinalApplicationStatus.SUCCEEDED, "", "");
  FinishApplicationMasterResponse response =
      amClient.finishApplicationMaster(request);
  Assert.assertEquals(response,
      this.cluster.createFakeFinishApplicationMasterResponse());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ApplicationMasterProtocolPBClientImpl.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  FinishApplicationMasterRequestProto requestProto =
      ((FinishApplicationMasterRequestPBImpl) request).getProto();
  try {
    return new FinishApplicationMasterResponsePBImpl(
      proxy.finishApplicationMaster(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestRPCFactories.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  // TODO Auto-generated method stub
  return null;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ProtocolHATestBase.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  resetStartFailoverFlag(true);
  // make sure failover has been triggered
  Assert.assertTrue(waittingForFailOver());
  return createFakeFinishApplicationMasterResponse();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestApplicationMasterServiceProtocolOnHA.java   
@Test(timeout = 15000)
public void testFinishApplicationMasterOnHA() throws YarnException,
    IOException {
  FinishApplicationMasterRequest request =
      FinishApplicationMasterRequest.newInstance(
          FinalApplicationStatus.SUCCEEDED, "", "");
  FinishApplicationMasterResponse response =
      amClient.finishApplicationMaster(request);
  Assert.assertEquals(response,
      this.cluster.createFakeFinishApplicationMasterResponse());
}
项目:hadoop-plus    文件:ApplicationMasterProtocolPBClientImpl.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  FinishApplicationMasterRequestProto requestProto =
      ((FinishApplicationMasterRequestPBImpl) request).getProto();
  try {
    return new FinishApplicationMasterResponsePBImpl(
      proxy.finishApplicationMaster(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
项目:hadoop-plus    文件:TestRPCFactories.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  // TODO Auto-generated method stub
  return null;
}
项目:hadoop-plus    文件:ApplicationMasterService.java   
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {

  ApplicationAttemptId applicationAttemptId = authorizeRequest();

  AllocateResponse lastResponse = responseMap.get(applicationAttemptId);
  if (lastResponse == null) {
    String message = "Application doesn't exist in cache "
        + applicationAttemptId;
    LOG.error(message);
    throw RPCUtil.getRemoteException(message);
  }

  // Allow only one thread in AM to do finishApp at a time.
  synchronized (lastResponse) {

    this.amLivelinessMonitor.receivedPing(applicationAttemptId);

    rmContext.getDispatcher().getEventHandler().handle(
        new RMAppAttemptUnregistrationEvent(applicationAttemptId, request
            .getTrackingUrl(), request.getFinalApplicationStatus(), request
            .getDiagnostics()));

    FinishApplicationMasterResponse response = recordFactory
        .newRecordInstance(FinishApplicationMasterResponse.class);
    return response;
  }
}