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