Search in sources :

Example 1 with NodeInfo

use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo in project hadoop by apache.

the class RMWebServices method getNodes.

/**
   * Returns all nodes in the cluster. If the states param is given, returns
   * all nodes that are in the comma-separated list of states.
   */
@GET
@Path("/nodes")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public NodesInfo getNodes(@QueryParam("states") String states) {
    init();
    ResourceScheduler sched = this.rm.getResourceScheduler();
    if (sched == null) {
        throw new NotFoundException("Null ResourceScheduler instance");
    }
    EnumSet<NodeState> acceptedStates;
    if (states == null) {
        acceptedStates = EnumSet.allOf(NodeState.class);
    } else {
        acceptedStates = EnumSet.noneOf(NodeState.class);
        for (String stateStr : states.split(",")) {
            acceptedStates.add(NodeState.valueOf(StringUtils.toUpperCase(stateStr)));
        }
    }
    Collection<RMNode> rmNodes = RMServerUtils.queryRMNodes(this.rm.getRMContext(), acceptedStates);
    NodesInfo nodesInfo = new NodesInfo();
    for (RMNode rmNode : rmNodes) {
        NodeInfo nodeInfo = new NodeInfo(rmNode, sched);
        if (EnumSet.of(NodeState.LOST, NodeState.DECOMMISSIONED, NodeState.REBOOTED).contains(rmNode.getState())) {
            nodeInfo.setNodeHTTPAddress(EMPTY);
        }
        nodesInfo.add(nodeInfo);
    }
    return nodesInfo;
}
Also used : RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) NodeState(org.apache.hadoop.yarn.api.records.NodeState) NodesInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo) LabelsToNodesInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LabelsToNodesInfo) NodeInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with NodeInfo

use of org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo in project hadoop by apache.

the class RMWebServices method getNode.

@GET
@Path("/nodes/{nodeId}")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public NodeInfo getNode(@PathParam("nodeId") String nodeId) {
    init();
    if (nodeId == null || nodeId.isEmpty()) {
        throw new NotFoundException("nodeId, " + nodeId + ", is empty or null");
    }
    ResourceScheduler sched = this.rm.getResourceScheduler();
    if (sched == null) {
        throw new NotFoundException("Null ResourceScheduler instance");
    }
    NodeId nid = NodeId.fromString(nodeId);
    RMNode ni = this.rm.getRMContext().getRMNodes().get(nid);
    boolean isInactive = false;
    if (ni == null) {
        ni = this.rm.getRMContext().getInactiveRMNodes().get(nid);
        if (ni == null) {
            throw new NotFoundException("nodeId, " + nodeId + ", is not found");
        }
        isInactive = true;
    }
    NodeInfo nodeInfo = new NodeInfo(ni, sched);
    if (isInactive) {
        nodeInfo.setNodeHTTPAddress(EMPTY);
    }
    return nodeInfo;
}
Also used : RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) NodeInfo(org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo) NodeId(org.apache.hadoop.yarn.api.records.NodeId) NotFoundException(org.apache.hadoop.yarn.webapp.NotFoundException) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) 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 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)2 ResourceScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler)2 NodeInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodeInfo)2 NotFoundException (org.apache.hadoop.yarn.webapp.NotFoundException)2 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 NodeState (org.apache.hadoop.yarn.api.records.NodeState)1 LabelsToNodesInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.LabelsToNodesInfo)1 NodesInfo (org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NodesInfo)1