Search in sources :

Example 1 with ContainerInfo

use of org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainerInfo in project hadoop by apache.

the class NMWebServices method getNodeContainers.

@GET
@Path("/containers")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public ContainersInfo getNodeContainers(@javax.ws.rs.core.Context HttpServletRequest hsr) {
    init();
    ContainersInfo allContainers = new ContainersInfo();
    for (Entry<ContainerId, Container> entry : this.nmContext.getContainers().entrySet()) {
        if (entry.getValue() == null) {
            // just skip it
            continue;
        }
        ContainerInfo info = new ContainerInfo(this.nmContext, entry.getValue(), uriInfo.getBaseUri().toString(), webapp.name(), hsr.getRemoteUser());
        allContainers.add(info);
    }
    return allContainers;
}
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) ContainersInfo(org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainersInfo) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with ContainerInfo

use of org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainerInfo 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

GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 Container (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)2 ContainerInfo (org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainerInfo)2 IOException (java.io.IOException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1 ContainersInfo (org.apache.hadoop.yarn.server.nodemanager.webapp.dao.ContainersInfo)1 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)1 NotFoundException (org.apache.hadoop.yarn.webapp.NotFoundException)1