Search in sources :

Example 51 with Priority

use of org.apache.hadoop.yarn.api.records.Priority in project hadoop by apache.

the class RMAppManager method updateApplicationPriority.

/**
   * updateApplicationPriority will invoke scheduler api to update the
   * new priority to RM and StateStore.
   * @param callerUGI user
   * @param applicationId Application Id
   * @param newAppPriority proposed new application priority
   * @throws YarnException Handle exceptions
   */
public void updateApplicationPriority(UserGroupInformation callerUGI, ApplicationId applicationId, Priority newAppPriority) throws YarnException {
    RMApp app = this.rmContext.getRMApps().get(applicationId);
    synchronized (applicationId) {
        if (app == null || app.isAppInCompletedStates()) {
            return;
        }
        // Create a future object to capture exceptions from StateStore.
        SettableFuture<Object> future = SettableFuture.create();
        // Invoke scheduler api to update priority in scheduler and to
        // State Store.
        Priority appPriority = rmContext.getScheduler().updateApplicationPriority(newAppPriority, applicationId, future, callerUGI);
        if (app.getApplicationPriority().equals(appPriority)) {
            return;
        }
        Futures.get(future, YarnException.class);
        // update in-memory
        ((RMAppImpl) app).setApplicationPriority(appPriority);
    }
    // Update the changed application state to timeline server
    rmContext.getSystemMetricsPublisher().appUpdated(app, System.currentTimeMillis());
}
Also used : RMAppImpl(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppImpl) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) Priority(org.apache.hadoop.yarn.api.records.Priority)

Example 52 with Priority

use of org.apache.hadoop.yarn.api.records.Priority in project hadoop by apache.

the class RMWebServices method updateApplicationPriority.

@PUT
@Path("/apps/{appid}/priority")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateApplicationPriority(AppPriority targetPriority, @Context HttpServletRequest hsr, @PathParam("appid") String appId) throws AuthorizationException, YarnException, InterruptedException, IOException {
    init();
    if (targetPriority == null) {
        throw new YarnException("Target Priority cannot be null");
    }
    UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
    if (callerUGI == null) {
        throw new AuthorizationException("Unable to obtain user name, user not authenticated");
    }
    if (UserGroupInformation.isSecurityEnabled() && isStaticUser(callerUGI)) {
        return Response.status(Status.FORBIDDEN).entity("The default static user cannot carry out this operation.").build();
    }
    String userName = callerUGI.getUserName();
    RMApp app = null;
    try {
        app = getRMAppForAppId(appId);
    } catch (NotFoundException e) {
        RMAuditLogger.logFailure(userName, AuditConstants.UPDATE_APP_PRIORITY, "UNKNOWN", "RMWebService", "Trying to update priority an absent application " + appId);
        throw e;
    }
    Priority priority = app.getApplicationPriority();
    if (priority == null || priority.getPriority() != targetPriority.getPriority()) {
        return modifyApplicationPriority(app, callerUGI, targetPriority.getPriority());
    }
    return Response.status(Status.OK).entity(targetPriority).build();
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) Priority(org.apache.hadoop.yarn.api.records.Priority) AppPriority(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppPriority) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 53 with Priority

use of org.apache.hadoop.yarn.api.records.Priority in project hadoop by apache.

the class RMWebServices method modifyApplicationPriority.

private Response modifyApplicationPriority(final RMApp app, UserGroupInformation callerUGI, final int appPriority) throws IOException, InterruptedException {
    String userName = callerUGI.getUserName();
    try {
        callerUGI.doAs(new PrivilegedExceptionAction<Void>() {

            @Override
            public Void run() throws IOException, YarnException {
                Priority priority = Priority.newInstance(appPriority);
                UpdateApplicationPriorityRequest request = UpdateApplicationPriorityRequest.newInstance(app.getApplicationId(), priority);
                rm.getClientRMService().updateApplicationPriority(request);
                return null;
            }
        });
    } catch (UndeclaredThrowableException ue) {
        // bubble that up to the user
        if (ue.getCause() instanceof YarnException) {
            YarnException ye = (YarnException) ue.getCause();
            if (ye.getCause() instanceof AccessControlException) {
                String appId = app.getApplicationId().toString();
                String msg = "Unauthorized attempt to change priority of appid " + appId + " by remote user " + userName;
                return Response.status(Status.FORBIDDEN).entity(msg).build();
            } else if (ye.getMessage().startsWith("Application in") && ye.getMessage().endsWith("state cannot be update priority.")) {
                return Response.status(Status.BAD_REQUEST).entity(ye.getMessage()).build();
            } else {
                throw ue;
            }
        } else {
            throw ue;
        }
    }
    AppPriority ret = new AppPriority(app.getApplicationPriority().getPriority());
    return Response.status(Status.OK).entity(ret).build();
}
Also used : AppPriority(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppPriority) Priority(org.apache.hadoop.yarn.api.records.Priority) AppPriority(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppPriority) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) UpdateApplicationPriorityRequest(org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest) AccessControlException(java.security.AccessControlException) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 54 with Priority

use of org.apache.hadoop.yarn.api.records.Priority in project hadoop by apache.

the class MockRM method submitApp.

public RMApp submitApp(int masterMemory, long attemptFailuresValidityInterval, boolean keepContainers) throws Exception {
    Resource resource = Records.newRecord(Resource.class);
    resource.setMemorySize(masterMemory);
    Priority priority = Priority.newInstance(0);
    return submitApp(resource, "", UserGroupInformation.getCurrentUser().getShortUserName(), null, false, null, super.getConfig().getInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, YarnConfiguration.DEFAULT_RM_AM_MAX_ATTEMPTS), null, null, true, keepContainers, false, null, attemptFailuresValidityInterval, null, true, priority);
}
Also used : Priority(org.apache.hadoop.yarn.api.records.Priority) Resource(org.apache.hadoop.yarn.api.records.Resource)

Example 55 with Priority

use of org.apache.hadoop.yarn.api.records.Priority in project hadoop by apache.

the class FSQueue method getPriority.

@Override
public Priority getPriority() {
    Priority p = recordFactory.newRecordInstance(Priority.class);
    p.setPriority(1);
    return p;
}
Also used : Priority(org.apache.hadoop.yarn.api.records.Priority)

Aggregations

Priority (org.apache.hadoop.yarn.api.records.Priority)216 Test (org.junit.Test)139 Resource (org.apache.hadoop.yarn.api.records.Resource)109 Container (org.apache.hadoop.yarn.api.records.Container)64 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)62 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)49 NodeId (org.apache.hadoop.yarn.api.records.NodeId)43 FiCaSchedulerApp (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp)40 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)40 Configuration (org.apache.hadoop.conf.Configuration)37 FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)34 ArrayList (java.util.ArrayList)33 ResourceLimits (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits)31 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)30 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)29 TaskSchedulerContextDrainable (org.apache.tez.dag.app.rm.TestTaskSchedulerHelpers.TaskSchedulerContextDrainable)27 ResourceRequest (org.apache.hadoop.yarn.api.records.ResourceRequest)26 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)25 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)24 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)23