Beispiel #1
0
 @Override
 public List<NodeReport> getNodeReports(NodeState... states) throws YarnException, IOException {
   EnumSet<NodeState> statesSet =
       (states.length == 0) ? EnumSet.allOf(NodeState.class) : EnumSet.noneOf(NodeState.class);
   for (NodeState state : states) {
     statesSet.add(state);
   }
   GetClusterNodesRequest request = GetClusterNodesRequest.newInstance(statesSet);
   GetClusterNodesResponse response = rmClient.getClusterNodes(request);
   return response.getNodeReports();
 }
 /**
  * Get all the nodes in the cluster, this method generate RPC
  *
  * @return host names
  * @throws YarnException
  */
 private List<String> getClusterNodes() throws YarnException {
   List<String> result = new ArrayList<String>();
   GetClusterNodesRequest clusterNodesReq = Records.newRecord(GetClusterNodesRequest.class);
   try {
     GetClusterNodesResponse clusterNodesResp =
         applicationsManager.getClusterNodes(clusterNodesReq);
     List<NodeReport> nodeReports = clusterNodesResp.getNodeReports();
     for (NodeReport nodeReport : nodeReports) {
       result.add(nodeReport.getNodeId().getHost());
     }
   } catch (IOException e) {
     LOG.error("error getting cluster nodes from AM");
     throw new YarnException(e);
   }
   return result;
 }