Search in sources :

Example 1 with FailApplicationAttemptResponse

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;
}
Also used : FailApplicationAttemptResponse(org.apache.hadoop.yarn.api.protocolrecords.FailApplicationAttemptResponse) FailApplicationAttemptRequest(org.apache.hadoop.yarn.api.protocolrecords.FailApplicationAttemptRequest) ApplicationClientProtocol(org.apache.hadoop.yarn.api.ApplicationClientProtocol)

Example 2 with FailApplicationAttemptResponse

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;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) AccessControlException(java.security.AccessControlException) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) IOException(java.io.IOException) FailApplicationAttemptResponse(org.apache.hadoop.yarn.api.protocolrecords.FailApplicationAttemptResponse) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) RMAppAttemptEvent(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent)

Aggregations

FailApplicationAttemptResponse (org.apache.hadoop.yarn.api.protocolrecords.FailApplicationAttemptResponse)2 IOException (java.io.IOException)1 AccessControlException (java.security.AccessControlException)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 ApplicationClientProtocol (org.apache.hadoop.yarn.api.ApplicationClientProtocol)1 FailApplicationAttemptRequest (org.apache.hadoop.yarn.api.protocolrecords.FailApplicationAttemptRequest)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 ApplicationAttemptNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException)1 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)1 RMAppAttemptEvent (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent)1