use of org.apache.hadoop.yarn.api.protocolrecords.FailApplicationAttemptResponse in project hadoop by apache.
the class MockRM method failApplicationAttempt.
public FailApplicationAttemptResponse failApplicationAttempt(ApplicationAttemptId attemptId) throws Exception {
ApplicationClientProtocol client = getClientRMService();
FailApplicationAttemptRequest req = FailApplicationAttemptRequest.newInstance(attemptId);
FailApplicationAttemptResponse response = client.failApplicationAttempt(req);
drainEventsImplicitly();
return response;
}
use of org.apache.hadoop.yarn.api.protocolrecords.FailApplicationAttemptResponse in project hadoop by apache.
the class ClientRMService method failApplicationAttempt.
@SuppressWarnings("unchecked")
@Override
public FailApplicationAttemptResponse failApplicationAttempt(FailApplicationAttemptRequest request) throws YarnException {
ApplicationAttemptId attemptId = request.getApplicationAttemptId();
ApplicationId applicationId = attemptId.getApplicationId();
UserGroupInformation callerUGI;
try {
callerUGI = UserGroupInformation.getCurrentUser();
} catch (IOException ie) {
LOG.info("Error getting UGI ", ie);
RMAuditLogger.logFailure("UNKNOWN", AuditConstants.FAIL_ATTEMPT_REQUEST, "UNKNOWN", "ClientRMService", "Error getting UGI", applicationId, attemptId);
throw RPCUtil.getRemoteException(ie);
}
RMApp application = this.rmContext.getRMApps().get(applicationId);
if (application == null) {
RMAuditLogger.logFailure(callerUGI.getUserName(), AuditConstants.FAIL_ATTEMPT_REQUEST, "UNKNOWN", "ClientRMService", "Trying to fail an attempt of an absent application", applicationId, attemptId);
throw new ApplicationNotFoundException("Trying to fail an attempt " + attemptId + " of an absent application " + applicationId);
}
RMAppAttempt appAttempt = application.getAppAttempts().get(attemptId);
if (appAttempt == null) {
throw new ApplicationAttemptNotFoundException("ApplicationAttempt with id '" + attemptId + "' doesn't exist in RM.");
}
if (!checkAccess(callerUGI, application.getUser(), ApplicationAccessType.MODIFY_APP, application)) {
RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.FAIL_ATTEMPT_REQUEST, "User doesn't have permissions to " + ApplicationAccessType.MODIFY_APP.toString(), "ClientRMService", AuditConstants.UNAUTHORIZED_USER, applicationId);
throw RPCUtil.getRemoteException(new AccessControlException("User " + callerUGI.getShortUserName() + " cannot perform operation " + ApplicationAccessType.MODIFY_APP.name() + " on " + applicationId));
}
FailApplicationAttemptResponse response = recordFactory.newRecordInstance(FailApplicationAttemptResponse.class);
if (!ACTIVE_APP_STATES.contains(application.getState())) {
if (COMPLETED_APP_STATES.contains(application.getState())) {
RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.FAIL_ATTEMPT_REQUEST, "ClientRMService", applicationId);
return response;
}
}
this.rmContext.getDispatcher().getEventHandler().handle(new RMAppAttemptEvent(attemptId, RMAppAttemptEventType.FAIL, "Attempt failed by user."));
RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.FAIL_ATTEMPT_REQUEST, "ClientRMService", applicationId, attemptId);
return response;
}
Aggregations