Search in sources :

Example 1 with UpdateApplicationTimeoutsResponse

use of org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse in project hadoop by apache.

the class ClientRMService method updateApplicationTimeouts.

@Override
public UpdateApplicationTimeoutsResponse updateApplicationTimeouts(UpdateApplicationTimeoutsRequest request) throws YarnException, IOException {
    ApplicationId applicationId = request.getApplicationId();
    Map<ApplicationTimeoutType, String> applicationTimeouts = request.getApplicationTimeouts();
    UserGroupInformation callerUGI = getCallerUgi(applicationId, AuditConstants.UPDATE_APP_TIMEOUTS);
    RMApp application = verifyUserAccessForRMApp(applicationId, callerUGI, AuditConstants.UPDATE_APP_TIMEOUTS);
    if (applicationTimeouts.isEmpty()) {
        String message = "At least one ApplicationTimeoutType should be configured" + " for updating timeouts.";
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService", message, applicationId);
        throw RPCUtil.getRemoteException(message);
    }
    UpdateApplicationTimeoutsResponse response = recordFactory.newRecordInstance(UpdateApplicationTimeoutsResponse.class);
    RMAppState state = application.getState();
    if (!EnumSet.of(RMAppState.SUBMITTED, RMAppState.ACCEPTED, RMAppState.RUNNING).contains(state)) {
        if (COMPLETED_APP_STATES.contains(state)) {
            // If Application is in any of the final states, update timeout
            // can be skipped rather throwing exception.
            RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "ClientRMService", applicationId);
            return response;
        }
        String msg = "Application is in " + state + " state can not update timeout.";
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService", msg);
        throw RPCUtil.getRemoteException(msg);
    }
    try {
        rmAppManager.updateApplicationTimeout(application, applicationTimeouts);
    } catch (YarnException ex) {
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "UNKNOWN", "ClientRMService", ex.getMessage());
        throw ex;
    }
    RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_TIMEOUTS, "ClientRMService", applicationId);
    return response;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppState(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState) ApplicationTimeoutType(org.apache.hadoop.yarn.api.records.ApplicationTimeoutType) UpdateApplicationTimeoutsResponse(org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 UpdateApplicationTimeoutsResponse (org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 ApplicationTimeoutType (org.apache.hadoop.yarn.api.records.ApplicationTimeoutType)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1 RMAppState (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState)1