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

项目:tajo-cdh    文件:YarnTajoResourceManager.java   
@Override
public void stopQueryMaster(QueryId queryId) {
  try {
    FinalApplicationStatus appStatus = FinalApplicationStatus.UNDEFINED;
    QueryInProgress queryInProgress = masterContext.getQueryJobManager().getQueryInProgress(queryId);
    if(queryInProgress == null) {
      return;
    }
    TajoProtos.QueryState state = queryInProgress.getQueryInfo().getQueryState();
    if (state == TajoProtos.QueryState.QUERY_SUCCEEDED) {
      appStatus = FinalApplicationStatus.SUCCEEDED;
    } else if (state == TajoProtos.QueryState.QUERY_FAILED || state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    } else if (state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    }
    FinishApplicationMasterRequest request = recordFactory
        .newRecordInstance(FinishApplicationMasterRequest.class);
    request.setAppAttemptId(ApplicationIdUtils.createApplicationAttemptId(queryId));
    request.setFinishApplicationStatus(appStatus);
    request.setDiagnostics("QueryMaster shutdown by TajoMaster.");
    rmClient.finishApplicationMaster(request);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }
}
项目:incubator-tajo    文件:YarnTajoResourceManager.java   
@Override
public void stopQueryMaster(QueryId queryId) {
  try {
    FinalApplicationStatus appStatus = FinalApplicationStatus.UNDEFINED;
    QueryInProgress queryInProgress = masterContext.getQueryJobManager().getQueryInProgress(queryId);
    if(queryInProgress == null) {
      return;
    }
    TajoProtos.QueryState state = queryInProgress.getQueryInfo().getQueryState();
    if (state == TajoProtos.QueryState.QUERY_SUCCEEDED) {
      appStatus = FinalApplicationStatus.SUCCEEDED;
    } else if (state == TajoProtos.QueryState.QUERY_FAILED || state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    } else if (state == TajoProtos.QueryState.QUERY_ERROR) {
      appStatus = FinalApplicationStatus.FAILED;
    }
    FinishApplicationMasterRequest request = recordFactory
        .newRecordInstance(FinishApplicationMasterRequest.class);
    request.setFinalApplicationStatus(appStatus);
    request.setDiagnostics("QueryMaster shutdown by TajoMaster.");
    rmClient.finishApplicationMaster(request);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }
}
项目:hadoop    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am, FinishApplicationMasterRequest req) throws Exception {
  RMState rmState =
      ((MemoryRMStateStore) rm.getRMContext().getStateStore()).getState();
  Map<ApplicationId, ApplicationStateData> rmAppState =
      rmState.getApplicationState();
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
  // check that app/attempt is saved with the final state
  ApplicationStateData appState = rmAppState.get(rmApp.getApplicationId());
  Assert
    .assertEquals(RMAppState.FINISHED, appState.getState());
  Assert.assertEquals(RMAppAttemptState.FINISHED,
    appState.getAttempt(am.getApplicationAttemptId()).getState());
}
项目:hadoop    文件:MockAM.java   
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
    boolean waitForStateRunning) throws Exception {
  if (waitForStateRunning) {
    waitForState(RMAppAttemptState.RUNNING);
  }
  if (ugi == null) {
    ugi =  UserGroupInformation.createRemoteUser(attemptId.toString());
    Token<AMRMTokenIdentifier> token =
        context.getRMApps()
            .get(attemptId.getApplicationId())
            .getRMAppAttempt(attemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
  }
  try {
    ugi.doAs(new PrivilegedExceptionAction<Object>() {
      @Override
      public Object run() throws Exception {
        amRMProtocol.finishApplicationMaster(req);
        return null;
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
项目: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    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am, FinishApplicationMasterRequest req) throws Exception {
  RMState rmState =
      ((MemoryRMStateStore) rm.getRMContext().getStateStore()).getState();
  Map<ApplicationId, ApplicationStateData> rmAppState =
      rmState.getApplicationState();
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
  // check that app/attempt is saved with the final state
  ApplicationStateData appState = rmAppState.get(rmApp.getApplicationId());
  Assert
    .assertEquals(RMAppState.FINISHED, appState.getState());
  Assert.assertEquals(RMAppAttemptState.FINISHED,
    appState.getAttempt(am.getApplicationAttemptId()).getState());
}
项目:aliyun-oss-hadoop-fs    文件:MockAM.java   
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
    boolean waitForStateRunning) throws Exception {
  if (waitForStateRunning) {
    waitForState(RMAppAttemptState.RUNNING);
  }
  if (ugi == null) {
    ugi =  UserGroupInformation.createRemoteUser(attemptId.toString());
    Token<AMRMTokenIdentifier> token =
        context.getRMApps()
            .get(attemptId.getApplicationId())
            .getRMAppAttempt(attemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
  }
  try {
    ugi.doAs(new PrivilegedExceptionAction<Object>() {
      @Override
      public Object run() throws Exception {
        amRMProtocol.finishApplicationMaster(req);
        return null;
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
项目: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    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am, FinishApplicationMasterRequest req) throws Exception {
  RMState rmState =
      ((MemoryRMStateStore) rm.getRMContext().getStateStore()).getState();
  Map<ApplicationId, ApplicationStateData> rmAppState =
      rmState.getApplicationState();
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
  // check that app/attempt is saved with the final state
  ApplicationStateData appState = rmAppState.get(rmApp.getApplicationId());
  Assert
    .assertEquals(RMAppState.FINISHED, appState.getState());
  Assert.assertEquals(RMAppAttemptState.FINISHED,
    appState.getAttempt(am.getApplicationAttemptId()).getState());
}
项目:big-c    文件:MockAM.java   
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
    boolean waitForStateRunning) throws Exception {
  if (waitForStateRunning) {
    waitForState(RMAppAttemptState.RUNNING);
  }
  if (ugi == null) {
    ugi =  UserGroupInformation.createRemoteUser(attemptId.toString());
    Token<AMRMTokenIdentifier> token =
        context.getRMApps()
            .get(attemptId.getApplicationId())
            .getRMAppAttempt(attemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
  }
  try {
    ugi.doAs(new PrivilegedExceptionAction<Object>() {
      @Override
      public Object run() throws Exception {
        amRMProtocol.finishApplicationMaster(req);
        return null;
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
项目: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);
  }
}
项目:apex-core    文件:StreamingAppMasterService.java   
private void finishApplication(FinalApplicationStatus finalStatus) throws YarnException, IOException
{
  LOG.info("Application completed. Signalling finish to RM");
  FinishApplicationMasterRequest finishReq = Records.newRecord(FinishApplicationMasterRequest.class);
  finishReq.setFinalApplicationStatus(finalStatus);

  if (finalStatus != FinalApplicationStatus.SUCCEEDED) {
    String diagnostics = "Diagnostics." + " completed=" + numCompletedContainers.get() + ", allocated=" + allocatedContainers.size() + ", failed=" + numFailedContainers.get();
    if (!StringUtils.isEmpty(dnmgr.shutdownDiagnosticsMessage)) {
      diagnostics += "\n";
      diagnostics += dnmgr.shutdownDiagnosticsMessage;
    }
    // YARN-208 - as of 2.0.1-alpha dropped by the RM
    finishReq.setDiagnostics(diagnostics);
    // expected termination of the master process
    // application status and diagnostics message are set above
  }
  LOG.info("diagnostics: " + finishReq.getDiagnostics());
  amRmClient.unregisterApplicationMaster(finishReq.getFinalApplicationStatus(), finishReq.getDiagnostics(), null);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am, FinishApplicationMasterRequest req) throws Exception {
  RMState rmState =
      ((MemoryRMStateStore) rm.getRMContext().getStateStore()).getState();
  Map<ApplicationId, ApplicationState> rmAppState =
      rmState.getApplicationState();
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
  // check that app/attempt is saved with the final state
  ApplicationState appState = rmAppState.get(rmApp.getApplicationId());
  Assert
    .assertEquals(RMAppState.FINISHED, appState.getState());
  Assert.assertEquals(RMAppAttemptState.FINISHED,
    appState.getAttempt(am.getApplicationAttemptId()).getState());
}
项目:hadoop-2.6.0-cdh5.4.3    文件:MockAM.java   
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
    boolean waitForStateRunning) throws Exception {
  if (waitForStateRunning) {
    waitForState(RMAppAttemptState.RUNNING);
  }
  if (ugi == null) {
    ugi =  UserGroupInformation.createRemoteUser(attemptId.toString());
    Token<AMRMTokenIdentifier> token =
        context.getRMApps()
            .get(attemptId.getApplicationId())
            .getRMAppAttempt(attemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
  }
  try {
    ugi.doAs(new PrivilegedExceptionAction<Object>() {
      @Override
      public Object run() throws Exception {
        amRMProtocol.finishApplicationMaster(req);
        return null;
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
项目: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);
  }
}
项目:hadoop-plus    文件:MockAM.java   
public void unregisterAppAttempt() throws Exception {
  waitForState(RMAppAttemptState.RUNNING);
  final FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
        FinalApplicationStatus.SUCCEEDED, "", "");
  UserGroupInformation ugi =
      UserGroupInformation.createRemoteUser(attemptId.toString());
  Token<AMRMTokenIdentifier> token =
      context.getRMApps().get(attemptId.getApplicationId())
        .getRMAppAttempt(attemptId).getAMRMToken();
  ugi.addTokenIdentifier(token.decodeIdentifier());
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws Exception {
      amRMProtocol.finishApplicationMaster(req);
      return null;
    }
  });
}
项目: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    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am, FinishApplicationMasterRequest req) throws Exception {
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
  // check that app/attempt is saved with the final state
  RMState rmState = rm.getRMContext().getStateStore().loadState();
  Map<ApplicationId, ApplicationStateData> rmAppState =
      rmState.getApplicationState();
  ApplicationStateData appState = rmAppState.get(rmApp.getApplicationId());
  Assert
    .assertEquals(RMAppState.FINISHED, appState.getState());
  Assert.assertEquals(RMAppAttemptState.FINISHED,
    appState.getAttempt(am.getApplicationAttemptId()).getState());
}
项目:hops    文件:MockAM.java   
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
    boolean waitForStateRunning) throws Exception {
  if (waitForStateRunning) {
    waitForState(RMAppAttemptState.RUNNING);
  }
  if (ugi == null) {
    ugi =  UserGroupInformation.createRemoteUser(attemptId.toString(), false);
    Token<AMRMTokenIdentifier> token =
        context.getRMApps()
            .get(attemptId.getApplicationId())
            .getRMAppAttempt(attemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
  }
  try {
    ugi.doAs(new PrivilegedExceptionAction<Object>() {
      @Override
      public Object run() throws Exception {
        amRMProtocol.finishApplicationMaster(req);
        return null;
      }
    });
  } catch (UndeclaredThrowableException e) {
    throw (Exception) e.getCause();
  }
}
项目: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    文件:MockAM.java   
public void unregisterAppAttempt() throws Exception {
  waitForState(RMAppAttemptState.RUNNING);
  final FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
        FinalApplicationStatus.SUCCEEDED, "", "");
  UserGroupInformation ugi =
      UserGroupInformation.createRemoteUser(attemptId.toString());
  Token<AMRMTokenIdentifier> token =
      context.getRMApps().get(attemptId.getApplicationId())
        .getRMAppAttempt(attemptId).getAMRMToken();
  ugi.addTokenIdentifier(token.decodeIdentifier());
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws Exception {
      amRMProtocol.finishApplicationMaster(req);
      return null;
    }
  });
}
项目: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    文件:MockAM.java   
public void unregisterAppAttempt() throws Exception {
  waitForState(RMAppAttemptState.RUNNING);
  final FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
        FinalApplicationStatus.SUCCEEDED, "", "");
  UserGroupInformation ugi =
      UserGroupInformation.createRemoteUser(attemptId.toString());
  Token<AMRMTokenIdentifier> token =
      context.getRMApps().get(attemptId.getApplicationId())
        .getRMAppAttempt(attemptId).getAMRMToken();
  ugi.addTokenIdentifier(token.decodeIdentifier());
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws Exception {
      amRMProtocol.finishApplicationMaster(req);
      return null;
    }
  });
}
项目: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    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am, FinishApplicationMasterRequest req) throws Exception {
  RMState rmState =
      ((MemoryRMStateStore) rm.getRMContext().getStateStore()).getState();
  Map<ApplicationId, ApplicationState> rmAppState =
      rmState.getApplicationState();
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
  // check that app/attempt is saved with the final state
  ApplicationState appState = rmAppState.get(rmApp.getApplicationId());
  Assert
    .assertEquals(RMAppState.FINISHED, appState.getState());
  Assert.assertEquals(RMAppAttemptState.FINISHED,
    appState.getAttempt(am.getApplicationAttemptId()).getState());
}
项目:hadoop-on-lustre2    文件:MockAM.java   
public void unregisterAppAttempt(final FinishApplicationMasterRequest req,
    boolean waitForStateRunning) throws Exception {
  if (waitForStateRunning) {
    waitForState(RMAppAttemptState.RUNNING);
  }
  UserGroupInformation ugi =
      UserGroupInformation.createRemoteUser(attemptId.toString());
  Token<AMRMTokenIdentifier> token =
      context.getRMApps().get(attemptId.getApplicationId())
          .getRMAppAttempt(attemptId).getAMRMToken();
  ugi.addTokenIdentifier(token.decodeIdentifier());
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws Exception {
      amRMProtocol.finishApplicationMaster(req);
      return null;
    }
  });
}
项目: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    文件:TestRMRestart.java   
private void finishApplicationMaster(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am) throws Exception {
  final FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
        FinalApplicationStatus.SUCCEEDED, "", "");
  finishApplicationMaster(rmApp, rm, nm, am, req);
}
项目:hadoop    文件:MockRM.java   
public static void finishAMAndVerifyAppState(RMApp rmApp, MockRM rm, MockNM nm,
    MockAM am) throws Exception {
  FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
        FinalApplicationStatus.SUCCEEDED, "", "");
  am.unregisterAppAttempt(req,true);
  am.waitForState(RMAppAttemptState.FINISHING);
  nm.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.COMPLETE);
  am.waitForState(RMAppAttemptState.FINISHED);
  rm.waitForState(rmApp.getApplicationId(), RMAppState.FINISHED);
}
项目:hadoop    文件:MockAM.java   
public void unregisterAppAttempt(boolean waitForStateRunning)
    throws Exception {
  final FinishApplicationMasterRequest req =
      FinishApplicationMasterRequest.newInstance(
          FinalApplicationStatus.SUCCEEDED, "", "");
  unregisterAppAttempt(req, waitForStateRunning);
}
项目: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);
}