Search in sources :

Example 31 with RMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp in project hadoop by apache.

the class RMWebServices method getRMAppForAppId.

private RMApp getRMAppForAppId(String appId) {
    ApplicationId id = WebAppUtils.parseApplicationId(recordFactory, appId);
    RMApp app = rm.getRMContext().getRMApps().get(id);
    if (app == null) {
        throw new NotFoundException("app with id: " + appId + " not found");
    }
    return app;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 32 with RMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp in project hadoop by apache.

the class RMWebServices method getAppQueue.

@GET
@Path("/apps/{appid}/queue")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public AppQueue getAppQueue(@Context HttpServletRequest hsr, @PathParam("appid") String appId) throws AuthorizationException {
    init();
    UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
    String userName = "UNKNOWN-USER";
    if (callerUGI != null) {
        userName = callerUGI.getUserName();
    }
    RMApp app = null;
    try {
        app = getRMAppForAppId(appId);
    } catch (NotFoundException e) {
        RMAuditLogger.logFailure(userName, AuditConstants.GET_APP_QUEUE, "UNKNOWN", "RMWebService", "Trying to get queue of an absent application " + appId);
        throw e;
    }
    AppQueue ret = new AppQueue();
    ret.setQueue(app.getQueue());
    return ret;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) AppQueue(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppQueue) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 33 with RMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp in project hadoop by apache.

the class RMWebServices method updateAppState.

// can't return POJO because we can't control the status code
// it's always set to 200 when we need to allow it to be set
// to 202
@PUT
@Path("/apps/{appid}/state")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateAppState(AppState targetState, @Context HttpServletRequest hsr, @PathParam("appid") String appId) throws AuthorizationException, YarnException, InterruptedException, IOException {
    init();
    UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
    if (callerUGI == null) {
        String msg = "Unable to obtain user name, user not authenticated";
        throw new AuthorizationException(msg);
    }
    if (UserGroupInformation.isSecurityEnabled() && isStaticUser(callerUGI)) {
        String msg = "The default static user cannot carry out this operation.";
        return Response.status(Status.FORBIDDEN).entity(msg).build();
    }
    String userName = callerUGI.getUserName();
    RMApp app = null;
    try {
        app = getRMAppForAppId(appId);
    } catch (NotFoundException e) {
        RMAuditLogger.logFailure(userName, AuditConstants.KILL_APP_REQUEST, "UNKNOWN", "RMWebService", "Trying to kill an absent application " + appId);
        throw e;
    }
    if (!app.getState().toString().equals(targetState.getState())) {
        if (targetState.getState().equals(YarnApplicationState.KILLED.toString())) {
            return killApp(app, callerUGI, hsr, targetState.getDiagnostics());
        }
        throw new BadRequestException("Only '" + YarnApplicationState.KILLED.toString() + "' is allowed as a target state.");
    }
    AppState ret = new AppState();
    ret.setState(app.getState().toString());
    return Response.status(Status.OK).entity(ret).build();
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) AppState(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppState) 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 34 with RMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp 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 35 with RMApp

use of org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp in project hadoop by apache.

the class RMWebServices method updateAppQueue.

@PUT
@Path("/apps/{appid}/queue")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateAppQueue(AppQueue targetQueue, @Context HttpServletRequest hsr, @PathParam("appid") String appId) throws AuthorizationException, YarnException, InterruptedException, IOException {
    init();
    UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
    if (callerUGI == null) {
        String msg = "Unable to obtain user name, user not authenticated";
        throw new AuthorizationException(msg);
    }
    if (UserGroupInformation.isSecurityEnabled() && isStaticUser(callerUGI)) {
        String msg = "The default static user cannot carry out this operation.";
        return Response.status(Status.FORBIDDEN).entity(msg).build();
    }
    String userName = callerUGI.getUserName();
    RMApp app = null;
    try {
        app = getRMAppForAppId(appId);
    } catch (NotFoundException e) {
        RMAuditLogger.logFailure(userName, AuditConstants.MOVE_APP_REQUEST, "UNKNOWN", "RMWebService", "Trying to move an absent application " + appId);
        throw e;
    }
    if (!app.getQueue().equals(targetQueue.getQueue())) {
        // user is attempting to change queue.
        return moveApp(app, callerUGI, targetQueue.getQueue());
    }
    AppQueue ret = new AppQueue();
    ret.setQueue(app.getQueue());
    return Response.status(Status.OK).entity(ret).build();
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) AppQueue(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppQueue) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) 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)

Aggregations

RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)447 Test (org.junit.Test)350 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)196 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)132 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)124 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)116 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)105 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)99 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)97 RMAppAttempt (org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt)91 MemoryRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MemoryRMStateStore)68 Configuration (org.apache.hadoop.conf.Configuration)66 Container (org.apache.hadoop.yarn.api.records.Container)58 ArrayList (java.util.ArrayList)56 FiCaSchedulerApp (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp)53 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)44 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)44 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)42 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)41 NodeUpdateSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent)40