Search in sources :

Example 41 with NotFoundException

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

the class AMWebServices method getJobConf.

@GET
@Path("/jobs/{jobid}/conf")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public ConfInfo getJobConf(@Context HttpServletRequest hsr, @PathParam("jobid") String jid) {
    init();
    Job job = getJobFromJobIdString(jid, appCtx);
    checkAccess(job, hsr);
    ConfInfo info;
    try {
        info = new ConfInfo(job);
    } catch (IOException e) {
        throw new NotFoundException("unable to load configuration for job: " + jid);
    }
    return info;
}
Also used : ConfInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfInfo) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 42 with NotFoundException

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

the class AMWebServices method getTaskFromTaskIdString.

/**
   * convert a task id string to an actual task and handle all the error
   * checking.
   */
public static Task getTaskFromTaskIdString(String tid, Job job) throws NotFoundException {
    TaskId taskID;
    Task task;
    try {
        taskID = MRApps.toTaskID(tid);
    } catch (YarnRuntimeException e) {
        // unhandled exceptions
        throw new NotFoundException(e.getMessage());
    } catch (NumberFormatException ne) {
        throw new NotFoundException(ne.getMessage());
    } catch (IllegalArgumentException e) {
        throw new NotFoundException(e.getMessage());
    }
    if (taskID == null) {
        throw new NotFoundException("taskid " + tid + " not found or invalid");
    }
    task = job.getTask(taskID);
    if (task == null) {
        throw new NotFoundException("task not found with id " + tid);
    }
    return task;
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException)

Example 43 with NotFoundException

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

the class TimelineReaderWebServices method getEntity.

/**
   * Return a single entity of the given entity type and Id. If userid, flowname
   * and flowrun id which are optional query parameters are not specified, they
   * will be queried based on app id and cluster id from the flow context
   * information stored in underlying storage implementation.
   *
   * @param req Servlet request.
   * @param res Servlet response.
   * @param clusterId Cluster id to which the entity to be queried belongs to(
   *     Mandatory path param).
   * @param appId Application id to which the entity to be queried belongs to(
   *     Mandatory path param).
   * @param entityType Type of entity(Mandatory path param).
   * @param entityId Id of the entity to be fetched(Mandatory path param).
   * @param userId User id which should match for the entity(Optional query
   *     param).
   * @param flowName Flow name which should match for the entity(Optional query
   *     param).
   * @param flowRunId Run id which should match for the entity(Optional query
   *     param).
   * @param confsToRetrieve If specified, defines which configurations to
   *     retrieve and send back in response. These configs will be retrieved
   *     irrespective of whether configs are specified in fields to retrieve or
   *     not.
   * @param metricsToRetrieve If specified, defines which metrics to retrieve
   *     and send back in response. These metrics will be retrieved
   *     irrespective of whether metrics are specified in fields to retrieve or
   *     not.
   * @param fields Specifies which fields of the entity object to retrieve, see
   *     {@link Field}. All fields will be retrieved if fields=ALL. If not
   *     specified, 3 fields i.e. entity type, id and created time is returned
   *     (Optional query param).
   * @param metricsLimit If specified, defines the number of metrics to return.
   *     Considered only if fields contains METRICS/ALL or metricsToRetrieve is
   *     specified. Ignored otherwise. The maximum possible value for
   *     metricsLimit can be {@link Integer#MAX_VALUE}. If it is not specified
   *     or has a value less than 1, and metrics have to be retrieved, then
   *     metricsLimit will be considered as 1 i.e. latest single value of
   *     metric(s) will be returned. (Optional query param).
   *
   * @return If successful, a HTTP 200(OK) response having a JSON representing a
   *     <cite>TimelineEntity</cite> instance is returned.<br>
   *     On failures,<br>
   *     If any problem occurs in parsing request, HTTP 400(Bad Request) is
   *     returned.<br>
   *     If flow context information cannot be retrieved or entity for the given
   *     entity id cannot be found, HTTP 404(Not Found) is returned.<br>
   *     For all other errors while retrieving data, HTTP 500(Internal Server
   *     Error) is returned.
   */
@GET
@Path("/clusters/{clusterid}/apps/{appid}/entities/{entitytype}/{entityid}/")
@Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8)
public TimelineEntity getEntity(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("clusterid") String clusterId, @PathParam("appid") String appId, @PathParam("entitytype") String entityType, @PathParam("entityid") String entityId, @QueryParam("userid") String userId, @QueryParam("flowname") String flowName, @QueryParam("flowrunid") String flowRunId, @QueryParam("confstoretrieve") String confsToRetrieve, @QueryParam("metricstoretrieve") String metricsToRetrieve, @QueryParam("fields") String fields, @QueryParam("metricslimit") String metricsLimit) {
    String url = req.getRequestURI() + (req.getQueryString() == null ? "" : QUERY_STRING_SEP + req.getQueryString());
    UserGroupInformation callerUGI = TimelineReaderWebServicesUtils.getUser(req);
    LOG.info("Received URL " + url + " from user " + TimelineReaderWebServicesUtils.getUserName(callerUGI));
    long startTime = Time.monotonicNow();
    init(res);
    TimelineReaderManager timelineReaderManager = getTimelineReaderManager();
    TimelineEntity entity = null;
    try {
        entity = timelineReaderManager.getEntity(TimelineReaderWebServicesUtils.createTimelineReaderContext(clusterId, userId, flowName, flowRunId, appId, entityType, entityId), TimelineReaderWebServicesUtils.createTimelineDataToRetrieve(confsToRetrieve, metricsToRetrieve, fields, metricsLimit));
    } catch (Exception e) {
        handleException(e, url, startTime, "flowrunid");
    }
    long endTime = Time.monotonicNow();
    if (entity == null) {
        LOG.info("Processed URL " + url + " but entity not found" + " (Took " + (endTime - startTime) + " ms.)");
        throw new NotFoundException("Timeline entity {id: " + entityId + ", type: " + entityType + " } is not found");
    }
    LOG.info("Processed URL " + url + " (Took " + (endTime - startTime) + " ms.)");
    return entity;
}
Also used : NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ParseException(java.text.ParseException) WebApplicationException(javax.ws.rs.WebApplicationException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 44 with NotFoundException

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

the class HsWebServices method getJobConf.

@GET
@Path("/mapreduce/jobs/{jobid}/conf")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public ConfInfo getJobConf(@Context HttpServletRequest hsr, @PathParam("jobid") String jid) {
    init();
    Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
    checkAccess(job, hsr);
    ConfInfo info;
    try {
        info = new ConfInfo(job);
    } catch (IOException e) {
        throw new NotFoundException("unable to load configuration for job: " + jid);
    }
    return info;
}
Also used : ConfInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.ConfInfo) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 45 with NotFoundException

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

the class HsWebServices method getSingleTaskCounters.

@GET
@Path("/mapreduce/jobs/{jobid}/tasks/{taskid}/counters")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public JobTaskCounterInfo getSingleTaskCounters(@Context HttpServletRequest hsr, @PathParam("jobid") String jid, @PathParam("taskid") String tid) {
    init();
    Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
    checkAccess(job, hsr);
    TaskId taskID = MRApps.toTaskID(tid);
    if (taskID == null) {
        throw new NotFoundException("taskid " + tid + " not found or invalid");
    }
    Task task = job.getTask(taskID);
    if (task == null) {
        throw new NotFoundException("task not found with id " + tid);
    }
    return new JobTaskCounterInfo(task);
}
Also used : Task(org.apache.hadoop.mapreduce.v2.app.job.Task) TaskId(org.apache.hadoop.mapreduce.v2.api.records.TaskId) JobTaskCounterInfo(org.apache.hadoop.mapreduce.v2.app.webapp.dao.JobTaskCounterInfo) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) Job(org.apache.hadoop.mapreduce.v2.app.job.Job) 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