Search in sources :

Example 26 with NotFoundException

use of org.apache.hadoop.yarn.webapp.NotFoundException in project apex-core by apache.

the class StramWebServices method getContainer.

@GET
@Path(PATH_PHYSICAL_PLAN_CONTAINERS + "/{containerId}")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getContainer(@PathParam("containerId") String containerId) throws Exception {
    init();
    ContainerInfo ci = null;
    if (containerId.equals(System.getenv(ApplicationConstants.Environment.CONTAINER_ID.toString()))) {
        ci = dagManager.getAppMasterContainerInfo();
    } else {
        for (ContainerInfo containerInfo : dagManager.getCompletedContainerInfo()) {
            if (containerInfo.id.equals(containerId)) {
                ci = containerInfo;
            }
        }
        if (ci == null) {
            StreamingContainerAgent sca = dagManager.getContainerAgent(containerId);
            if (sca == null) {
                throw new NotFoundException();
            }
            ci = sca.getContainerInfo();
        }
    }
    return new JSONObject(objectMapper.writeValueAsString(ci));
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) StreamingContainerAgent(com.datatorrent.stram.StreamingContainerAgent) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 27 with NotFoundException

use of org.apache.hadoop.yarn.webapp.NotFoundException in project apex-core by apache.

the class StramWebServices method getPort.

@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/ports/{portName}")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getPort(@PathParam("operatorName") String operatorName, @PathParam("portName") String portName) {
    init();
    OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
    Set<LogicalPlan.InputPortMeta> inputPorts;
    Set<LogicalPlan.OutputPortMeta> outputPorts;
    if (logicalOperator == null) {
        ModuleMeta logicalModule = dagManager.getModuleMeta(operatorName);
        if (logicalModule == null) {
            throw new NotFoundException();
        }
        inputPorts = logicalModule.getInputStreams().keySet();
        outputPorts = logicalModule.getOutputStreams().keySet();
    } else {
        inputPorts = logicalOperator.getInputStreams().keySet();
        outputPorts = logicalOperator.getOutputStreams().keySet();
    }
    try {
        JSONObject resp = getPortObject(inputPorts, outputPorts, portName);
        if (resp != null) {
            return resp;
        }
    } catch (JSONException ex) {
        throw new RuntimeException(ex);
    }
    throw new NotFoundException();
}
Also used : ModuleMeta(com.datatorrent.stram.plan.logical.LogicalPlan.ModuleMeta) OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta) JSONObject(org.codehaus.jettison.json.JSONObject) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) JSONException(org.codehaus.jettison.json.JSONException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 28 with NotFoundException

use of org.apache.hadoop.yarn.webapp.NotFoundException in project apex-core by apache.

the class StramWebServices method setOperatorProperties.

// not supported by WebAppProxyServlet, can only be called directly
@POST
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/properties")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JSONObject setOperatorProperties(JSONObject request, @PathParam("operatorName") String operatorName) {
    init();
    OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
    if (logicalOperator == null) {
        throw new NotFoundException();
    }
    JSONObject response = new JSONObject();
    try {
        @SuppressWarnings("unchecked") Iterator<String> keys = request.keys();
        while (keys.hasNext()) {
            String key = keys.next();
            String val = request.isNull(key) ? null : request.getString(key);
            LOG.debug("Setting property for {}: {}={}", operatorName, key, val);
            dagManager.setOperatorProperty(operatorName, key, val);
        }
    } catch (JSONException ex) {
        LOG.warn("Got JSON Exception: ", ex);
    } catch (Exception ex) {
        LOG.error("Caught exception: ", ex);
        throw new RuntimeException(ex);
    }
    return response;
}
Also used : OperatorMeta(com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta) JSONObject(org.codehaus.jettison.json.JSONObject) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) JSONException(org.codehaus.jettison.json.JSONException) TimeoutException(java.util.concurrent.TimeoutException) JsonProcessingException(org.codehaus.jackson.JsonProcessingException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) JSONException(org.codehaus.jettison.json.JSONException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 29 with NotFoundException

use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.

the class RMWebServices method getAppState.

@GET
@Path("/apps/{appid}/state")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public AppState getAppState(@Context HttpServletRequest hsr, @PathParam("appid") String appId) throws AuthorizationException {
    init();
    UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
    String userName = "";
    if (callerUGI != null) {
        userName = callerUGI.getUserName();
    }
    RMApp app = null;
    try {
        app = getRMAppForAppId(appId);
    } catch (NotFoundException e) {
        RMAuditLogger.logFailure(userName, AuditConstants.GET_APP_STATE, "UNKNOWN", "RMWebService", "Trying to get state of an absent application " + appId);
        throw e;
    }
    AppState ret = new AppState();
    ret.setState(app.getState().toString());
    return ret;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) 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) GET(javax.ws.rs.GET)

Example 30 with NotFoundException

use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.

the class RMWebServices method getAppPriority.

@GET
@Path("/apps/{appid}/priority")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public AppPriority getAppPriority(@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_PRIORITY, "UNKNOWN", "RMWebService", "Trying to get priority of an absent application " + appId);
        throw e;
    }
    AppPriority ret = new AppPriority();
    ret.setPriority(app.getApplicationPriority().getPriority());
    return ret;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) AppPriority(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.AppPriority) 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)

Aggregations

NotFoundException (org.apache.hadoop.yarn.webapp.NotFoundException)49 Path (javax.ws.rs.Path)36 Produces (javax.ws.rs.Produces)35 GET (javax.ws.rs.GET)30 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)15 WebApplicationException (javax.ws.rs.WebApplicationException)14 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)14 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)11 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)11 JSONObject (org.codehaus.jettison.json.JSONObject)11 IOException (java.io.IOException)10 OperatorMeta (com.datatorrent.stram.plan.logical.LogicalPlan.OperatorMeta)8 ForbiddenException (org.apache.hadoop.yarn.webapp.ForbiddenException)7 Consumes (javax.ws.rs.Consumes)6 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)6 PUT (javax.ws.rs.PUT)5 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)5 JSONException (org.codehaus.jettison.json.JSONException)5 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)4 Application (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application)4