Search in sources :

Example 1 with SchedulerWrapper

use of org.apache.hadoop.yarn.sls.scheduler.SchedulerWrapper in project hadoop by apache.

the class AMSimulator method lastStep.

@Override
public void lastStep() throws Exception {
    LOG.info(MessageFormat.format("Application {0} is shutting down.", appId));
    // unregister tracking
    if (isTracked) {
        untrackApp();
    }
    // Finish AM container
    if (amContainer != null) {
        LOG.info("AM container = " + amContainer.getId() + " reported to finish");
        se.getNmMap().get(amContainer.getNodeId()).cleanupContainer(amContainer.getId());
    } else {
        LOG.info("AM container is null");
    }
    if (null == appAttemptId) {
        // it's unnecessary to finish am as well
        return;
    }
    // unregister application master
    final FinishApplicationMasterRequest finishAMRequest = recordFactory.newRecordInstance(FinishApplicationMasterRequest.class);
    finishAMRequest.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);
    UserGroupInformation ugi = UserGroupInformation.createRemoteUser(appAttemptId.toString());
    Token<AMRMTokenIdentifier> token = rm.getRMContext().getRMApps().get(appId).getRMAppAttempt(appAttemptId).getAMRMToken();
    ugi.addTokenIdentifier(token.decodeIdentifier());
    ugi.doAs(new PrivilegedExceptionAction<Object>() {

        @Override
        public Object run() throws Exception {
            rm.getApplicationMasterService().finishApplicationMaster(finishAMRequest);
            return null;
        }
    });
    simulateFinishTimeMS = System.currentTimeMillis() - SLSRunner.getRunner().getStartTimeMS();
    // record job running information
    ((SchedulerWrapper) rm.getResourceScheduler()).addAMRuntime(appId, traceStartTimeMS, traceFinishTimeMS, simulateStartTimeMS, simulateFinishTimeMS);
}
Also used : AMRMTokenIdentifier(org.apache.hadoop.yarn.security.AMRMTokenIdentifier) SchedulerWrapper(org.apache.hadoop.yarn.sls.scheduler.SchedulerWrapper) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) IOException(java.io.IOException) FinishApplicationMasterRequest(org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

IOException (java.io.IOException)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 FinishApplicationMasterRequest (org.apache.hadoop.yarn.api.protocolrecords.FinishApplicationMasterRequest)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 AMRMTokenIdentifier (org.apache.hadoop.yarn.security.AMRMTokenIdentifier)1 SchedulerWrapper (org.apache.hadoop.yarn.sls.scheduler.SchedulerWrapper)1