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