use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.
the class AHSWebServices method getContainerLogMeta.
private Response getContainerLogMeta(ApplicationId appId, String appOwner, final String nodeId, final String containerIdStr, boolean emptyLocalContainerLogMeta) {
try {
List<ContainerLogMeta> containerLogMeta = LogToolUtils.getContainerLogMetaFromRemoteFS(conf, appId, containerIdStr, nodeId, appOwner);
if (containerLogMeta.isEmpty()) {
throw new NotFoundException("Can not get log meta for container: " + containerIdStr);
}
List<ContainerLogsInfo> containersLogsInfo = new ArrayList<>();
for (ContainerLogMeta meta : containerLogMeta) {
ContainerLogsInfo logInfo = new ContainerLogsInfo(meta, ContainerLogAggregationType.AGGREGATED);
containersLogsInfo.add(logInfo);
}
if (emptyLocalContainerLogMeta) {
ContainerLogMeta emptyMeta = new ContainerLogMeta(containerIdStr, "N/A");
ContainerLogsInfo empty = new ContainerLogsInfo(emptyMeta, ContainerLogAggregationType.LOCAL);
containersLogsInfo.add(empty);
}
GenericEntity<List<ContainerLogsInfo>> meta = new GenericEntity<List<ContainerLogsInfo>>(containersLogsInfo) {
};
ResponseBuilder response = Response.ok(meta);
// Sending the X-Content-Type-Options response header with the value
// nosniff will prevent Internet Explorer from MIME-sniffing a response
// away from the declared content-type.
response.header("X-Content-Type-Options", "nosniff");
return response.build();
} catch (Exception ex) {
throw new WebApplicationException(ex);
}
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.
the class TimelineWebServices method getEntity.
/**
* Return a single entity of the given entity type and Id.
*/
@GET
@Path("/{entityType}/{entityId}")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
public TimelineEntity getEntity(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("entityType") String entityType, @PathParam("entityId") String entityId, @QueryParam("fields") String fields) {
init(res);
TimelineEntity entity = null;
try {
entity = timelineDataManager.getEntity(parseStr(entityType), parseStr(entityId), parseFieldsStr(fields, ","), getUser(req));
} catch (IllegalArgumentException e) {
throw new BadRequestException(e);
} catch (Exception e) {
LOG.error("Error getting entity", e);
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
if (entity == null) {
throw new NotFoundException("Timeline entity " + new EntityIdentifier(parseStr(entityId), parseStr(entityType)) + " is not found");
}
return entity;
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.
the class TimelineWebServices method getDomain.
/**
* Return a single domain of the given domain Id.
*/
@GET
@Path("/domain/{domainId}")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
public TimelineDomain getDomain(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("domainId") String domainId) {
init(res);
domainId = parseStr(domainId);
if (domainId == null || domainId.length() == 0) {
throw new BadRequestException("Domain ID is not specified.");
}
TimelineDomain domain = null;
try {
domain = timelineDataManager.getDomain(parseStr(domainId), getUser(req));
} catch (Exception e) {
LOG.error("Error getting domain", e);
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
if (domain == null) {
throw new NotFoundException("Timeline domain [" + domainId + "] is not found");
}
return domain;
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.
the class WebServices method getAppAttempt.
public AppAttemptInfo getAppAttempt(HttpServletRequest req, HttpServletResponse res, String appId, String appAttemptId) {
UserGroupInformation callerUGI = getUser(req);
ApplicationId aid = parseApplicationId(appId);
final ApplicationAttemptId aaid = parseApplicationAttemptId(appAttemptId);
validateIds(aid, aaid, null);
ApplicationAttemptReport appAttempt = null;
try {
if (callerUGI == null) {
GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(aaid);
appAttempt = appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
} else {
appAttempt = callerUGI.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {
@Override
public ApplicationAttemptReport run() throws Exception {
GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest.newInstance(aaid);
return appBaseProt.getApplicationAttemptReport(request).getApplicationAttemptReport();
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
}
if (appAttempt == null) {
throw new NotFoundException("app attempt with id: " + appAttemptId + " not found");
}
return new AppAttemptInfo(appAttempt);
}
use of org.apache.hadoop.yarn.webapp.NotFoundException in project hadoop by apache.
the class NMWebServices method getNodeContainer.
@GET
@Path("/containers/{containerid}")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public ContainerInfo getNodeContainer(@javax.ws.rs.core.Context HttpServletRequest hsr, @PathParam("containerid") String id) {
ContainerId containerId = null;
init();
try {
containerId = ContainerId.fromString(id);
} catch (Exception e) {
throw new BadRequestException("invalid container id, " + id);
}
Container container = nmContext.getContainers().get(containerId);
if (container == null) {
throw new NotFoundException("container with id, " + id + ", not found");
}
return new ContainerInfo(this.nmContext, container, uriInfo.getBaseUri().toString(), webapp.name(), hsr.getRemoteUser());
}
Aggregations