Search in sources :

Example 36 with NotFoundException

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);
    }
}
Also used : ContainerLogsInfo(org.apache.hadoop.yarn.server.webapp.dao.ContainerLogsInfo) WebApplicationException(javax.ws.rs.WebApplicationException) GenericEntity(javax.ws.rs.core.GenericEntity) ContainerLogMeta(org.apache.hadoop.yarn.logaggregation.ContainerLogMeta) ArrayList(java.util.ArrayList) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) List(java.util.List) ArrayList(java.util.ArrayList) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) WebApplicationException(javax.ws.rs.WebApplicationException) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException)

Example 37 with NotFoundException

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;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) EntityIdentifier(org.apache.hadoop.yarn.server.timeline.EntityIdentifier) TimelineEntity(org.apache.hadoop.yarn.api.records.timeline.TimelineEntity) ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) WebApplicationException(javax.ws.rs.WebApplicationException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 38 with NotFoundException

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;
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) TimelineDomain(org.apache.hadoop.yarn.api.records.timeline.TimelineDomain) ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) WebApplicationException(javax.ws.rs.WebApplicationException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 39 with NotFoundException

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);
}
Also used : AppAttemptInfo(org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo) ApplicationAttemptReport(org.apache.hadoop.yarn.api.records.ApplicationAttemptReport) GetApplicationAttemptReportRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) ForbiddenException(org.apache.hadoop.yarn.webapp.ForbiddenException) AuthorizationException(org.apache.hadoop.security.authorize.AuthorizationException) ContainerNotFoundException(org.apache.hadoop.yarn.exceptions.ContainerNotFoundException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ApplicationAttemptNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) WebApplicationException(javax.ws.rs.WebApplicationException) ApplicationNotFoundException(org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 40 with NotFoundException

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());
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ContainerInfo(org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainerInfo) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) WebApplicationException(javax.ws.rs.WebApplicationException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) IOException(java.io.IOException) BadRequestException(org.apache.hadoop.yarn.webapp.BadRequestException) 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