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());
}
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;
}
Aggregations