use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.
the class TimelineReaderWebServices method getApp.
/**
* Return a single app for given cluster id and app id. If userid, flow name
* 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 app to be queried belong to(
* Mandatory path param).
* @param appId Application id to be queried(Mandatory path param).
* @param flowName Flow name which should match for the app(Optional query
* param).
* @param flowRunId Run id which should match for the app(Optional query
* param).
* @param userId User id which should match for the app(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 app entity object to retrieve,
* see {@link Field}. All fields will be retrieved if fields=ALL. If not
* specified, 3 fields i.e. entity type(equivalent to YARN_APPLICATION),
* app id and app 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 app for the given
* app 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}/")
@Produces(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8)
public TimelineEntity getApp(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("clusterid") String clusterId, @PathParam("appid") String appId, @QueryParam("flowname") String flowName, @QueryParam("flowrunid") String flowRunId, @QueryParam("userid") String userId, @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, TimelineEntityType.YARN_APPLICATION.toString(), null), 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 app not found" + " (Took " + (endTime - startTime) + " ms.)");
throw new NotFoundException("App " + appId + " not found");
}
LOG.info("Processed URL " + url + " (Took " + (endTime - startTime) + " ms.)");
return entity;
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project apex-core by apache.
the class StramWebServices method getOperatorClasses.
@GET
@Path(PATH_OPERATOR_CLASSES)
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getOperatorClasses(@QueryParam("q") String searchTerm, @QueryParam("parent") String parent) {
init();
JSONObject result = new JSONObject();
JSONArray classNames = new JSONArray();
if (parent != null) {
if (parent.equals("chart")) {
parent = "com.datatorrent.lib.chart.ChartOperator";
} else if (parent.equals("filter")) {
parent = "com.datatorrent.common.util.SimpleFilterOperator";
}
}
try {
Set<String> operatorClasses = operatorDiscoverer.getOperatorClasses(parent, searchTerm);
for (String clazz : operatorClasses) {
JSONObject j = new JSONObject();
j.put("name", clazz);
classNames.put(j);
}
result.put("operatorClasses", classNames);
} catch (ClassNotFoundException ex) {
throw new NotFoundException();
} catch (JSONException ex) {
throw new RuntimeException(ex);
}
return result;
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project apex-core by apache.
the class StramWebServices method getOperatorAggregation.
@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/aggregation")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getOperatorAggregation(@PathParam("operatorName") String operatorName) throws Exception {
init();
OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
if (logicalOperator == null) {
throw new NotFoundException();
}
OperatorAggregationInfo operatorAggregationInfo = dagManager.getOperatorAggregationInfo(operatorName);
return new JSONObject(objectMapper.writeValueAsString(operatorAggregationInfo));
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project apex-core by apache.
the class StramWebServices method getOperatorProperties.
@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/properties")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getOperatorProperties(@PathParam("operatorName") String operatorName, @QueryParam("propertyName") String propertyName) throws IOException, JSONException {
init();
OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
BeanMap operatorProperties = null;
if (logicalOperator == null) {
ModuleMeta logicalModule = dagManager.getModuleMeta(operatorName);
if (logicalModule == null) {
throw new NotFoundException();
}
operatorProperties = LogicalPlanConfiguration.getObjectProperties(logicalModule.getOperator());
} else {
operatorProperties = LogicalPlanConfiguration.getObjectProperties(logicalOperator.getOperator());
}
Map<String, Object> m = getPropertiesAsMap(propertyName, operatorProperties);
return new JSONObject(objectMapper.writeValueAsString(m));
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project apex-core by apache.
the class StramWebServices method getPortAttributes.
@GET
@Path(PATH_LOGICAL_PLAN_OPERATORS + "/{operatorName}/ports/{portName}/attributes")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getPortAttributes(@PathParam("operatorName") String operatorName, @PathParam("portName") String portName, @QueryParam("attributeName") String attributeName) {
init();
OperatorMeta logicalOperator = dagManager.getLogicalPlan().getOperatorMeta(operatorName);
if (logicalOperator == null) {
throw new NotFoundException();
}
HashMap<String, String> map = new HashMap<>();
for (Map.Entry<Attribute<?>, Object> entry : dagManager.getPortAttributes(operatorName, portName).entrySet()) {
if (attributeName == null || entry.getKey().getSimpleName().equals(attributeName)) {
Map.Entry<Attribute<Object>, Object> entry1 = (Map.Entry<Attribute<Object>, Object>) (Map.Entry) entry;
map.put(entry1.getKey().getSimpleName(), entry1.getKey().codec.toString(entry1.getValue()));
}
}
return new JSONObject(map);
}
Aggregations