Search in sources :

Example 1 with UpdateApplicationPriorityResponse

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

the class TestClientRMService method testApplicationPriorityUpdation.

private void testApplicationPriorityUpdation(ClientRMService rmService, RMApp app1, int tobeUpdatedPriority, int expected) throws YarnException, IOException {
    UpdateApplicationPriorityRequest updateRequest = UpdateApplicationPriorityRequest.newInstance(app1.getApplicationId(), Priority.newInstance(tobeUpdatedPriority));
    UpdateApplicationPriorityResponse updateApplicationPriority = rmService.updateApplicationPriority(updateRequest);
    Assert.assertEquals("Incorrect priority has been set to application", expected, app1.getApplicationSubmissionContext().getPriority().getPriority());
    Assert.assertEquals("Incorrect priority has been returned", expected, updateApplicationPriority.getApplicationPriority().getPriority());
}
Also used : UpdateApplicationPriorityResponse(org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse) UpdateApplicationPriorityRequest(org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest)

Example 2 with UpdateApplicationPriorityResponse

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

the class ClientRMService method updateApplicationPriority.

@Override
public UpdateApplicationPriorityResponse updateApplicationPriority(UpdateApplicationPriorityRequest request) throws YarnException, IOException {
    ApplicationId applicationId = request.getApplicationId();
    Priority newAppPriority = request.getApplicationPriority();
    UserGroupInformation callerUGI = getCallerUgi(applicationId, AuditConstants.UPDATE_APP_PRIORITY);
    RMApp application = verifyUserAccessForRMApp(applicationId, callerUGI, AuditConstants.UPDATE_APP_PRIORITY);
    UpdateApplicationPriorityResponse response = recordFactory.newRecordInstance(UpdateApplicationPriorityResponse.class);
    // Update priority only when app is tracked by the scheduler
    if (!ACTIVE_APP_STATES.contains(application.getState())) {
        if (application.isAppInCompletedStates()) {
            // If Application is in any of the final states, change priority
            // can be skipped rather throwing exception.
            RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_PRIORITY, "ClientRMService", applicationId);
            response.setApplicationPriority(application.getApplicationPriority());
            return response;
        }
        String msg = "Application in " + application.getState() + " state cannot update priority.";
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_PRIORITY, "UNKNOWN", "ClientRMService", msg);
        throw new YarnException(msg);
    }
    try {
        rmAppManager.updateApplicationPriority(callerUGI, application.getApplicationId(), newAppPriority);
    } catch (YarnException ex) {
        RMAuditLogger.logFailure(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_PRIORITY, "UNKNOWN", "ClientRMService", ex.getMessage());
        throw ex;
    }
    RMAuditLogger.logSuccess(callerUGI.getShortUserName(), AuditConstants.UPDATE_APP_PRIORITY, "ClientRMService", applicationId);
    response.setApplicationPriority(application.getApplicationPriority());
    return response;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) UpdateApplicationPriorityResponse(org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse) Priority(org.apache.hadoop.yarn.api.records.Priority) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

UpdateApplicationPriorityResponse (org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse)2 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 UpdateApplicationPriorityRequest (org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 Priority (org.apache.hadoop.yarn.api.records.Priority)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1