Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode#getState()

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode#getState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SLSRunner.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private void waitForNodesRunning() throws InterruptedException {
  long startTimeMS = System.currentTimeMillis();
  while (true) {
    int numRunningNodes = 0;
    for (RMNode node : rm.getRMContext().getRMNodes().values()) {
      if (node.getState() == NodeState.RUNNING) {
        numRunningNodes ++;
      }
    }
    if (numRunningNodes == numNMs) {
      break;
    }
    LOG.info(MessageFormat.format("SLSRunner is waiting for all " +
            "nodes RUNNING. {0} of {1} NMs initialized.",
            numRunningNodes, numNMs));
    Thread.sleep(1000);
  }
  LOG.info(MessageFormat.format("SLSRunner takes {0} ms to launch all nodes.",
          (System.currentTimeMillis() - startTimeMS)));
}
 
Example 2
Source File: SLSRunner.java    From big-c with Apache License 2.0 6 votes vote down vote up
private void waitForNodesRunning() throws InterruptedException {
  long startTimeMS = System.currentTimeMillis();
  while (true) {
    int numRunningNodes = 0;
    for (RMNode node : rm.getRMContext().getRMNodes().values()) {
      if (node.getState() == NodeState.RUNNING) {
        numRunningNodes ++;
      }
    }
    if (numRunningNodes == numNMs) {
      break;
    }
    LOG.info(MessageFormat.format("SLSRunner is waiting for all " +
            "nodes RUNNING. {0} of {1} NMs initialized.",
            numRunningNodes, numNMs));
    Thread.sleep(1000);
  }
  LOG.info(MessageFormat.format("SLSRunner takes {0} ms to launch all nodes.",
          (System.currentTimeMillis() - startTimeMS)));
}
 
Example 3
Source File: NodeInfo.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public NodeInfo(RMNode ni, ResourceScheduler sched) {
  NodeId id = ni.getNodeID();
  SchedulerNodeReport report = sched.getNodeReport(id);
  this.numContainers = 0;
  this.usedMemoryMB = 0;
  this.availMemoryMB = 0;
  if (report != null) {
    this.numContainers = report.getNumContainers();
    this.usedMemoryMB = report.getUsedResource().getMemory();
    this.availMemoryMB = report.getAvailableResource().getMemory();
    this.usedVirtualCores = report.getUsedResource().getVirtualCores();
    this.availableVirtualCores = report.getAvailableResource().getVirtualCores();
    this.usedGpuCores = report.getUsedResource().getGpuCores();
    this.availableGpuCores = report.getAvailableResource().getGpuCores();
  }
  this.id = id.toString();
  this.rack = ni.getRackName();
  this.nodeHostName = ni.getHostName();
  this.state = ni.getState();
  this.nodeHTTPAddress = ni.getHttpAddress();
  this.lastHealthUpdate = ni.getLastHealthReportTime();
  this.healthReport = String.valueOf(ni.getHealthReport());
  this.version = ni.getNodeManagerVersion();
  
  // add labels
  Set<String> labelSet = ni.getNodeLabels();
  if (labelSet != null) {
    nodeLabels.addAll(labelSet);
    Collections.sort(nodeLabels);
  }
}
 
Example 4
Source File: NodeInfo.java    From big-c with Apache License 2.0 5 votes vote down vote up
public NodeInfo(RMNode ni, ResourceScheduler sched) {
  NodeId id = ni.getNodeID();
  SchedulerNodeReport report = sched.getNodeReport(id);
  this.numContainers = 0;
  this.usedMemoryMB = 0;
  this.availMemoryMB = 0;
  if (report != null) {
    this.numContainers = report.getNumContainers();
    this.usedMemoryMB = report.getUsedResource().getMemory();
    this.availMemoryMB = report.getAvailableResource().getMemory();
    this.usedVirtualCores = report.getUsedResource().getVirtualCores();
    this.availableVirtualCores = report.getAvailableResource().getVirtualCores();
  }
  this.id = id.toString();
  this.rack = ni.getRackName();
  this.nodeHostName = ni.getHostName();
  this.state = ni.getState();
  this.nodeHTTPAddress = ni.getHttpAddress();
  this.lastHealthUpdate = ni.getLastHealthReportTime();
  this.healthReport = String.valueOf(ni.getHealthReport());
  this.version = ni.getNodeManagerVersion();
  
  // add labels
  Set<String> labelSet = ni.getNodeLabels();
  if (labelSet != null) {
    nodeLabels.addAll(labelSet);
    Collections.sort(nodeLabels);
  }
}
 
Example 5
Source File: NodesPage.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
protected void render(Block html) {
  html._(MetricsOverviewTable.class);

  ResourceScheduler sched = rm.getResourceScheduler();
  String type = $(NODE_STATE);
  String labelFilter = $(NODE_LABEL, CommonNodeLabelsManager.ANY).trim();
  TBODY<TABLE<Hamlet>> tbody =
      html.table("#nodes").thead().tr()
          .th(".nodelabels", "Node Labels")
          .th(".rack", "Rack")
          .th(".state", "Node State")
          .th(".nodeaddress", "Node Address")
          .th(".nodehttpaddress", "Node HTTP Address")
          .th(".lastHealthUpdate", "Last health-update")
          .th(".healthReport", "Health-report")
          .th(".containers", "Containers")
          .th(".mem", "Mem Used")
          .th(".mem", "Mem Avail")
          .th(".vcores", "VCores Used")
          .th(".vcores", "VCores Avail")
          .th(".gcores", "GCores Used")
          .th(".gcores", "GCores Avail")
          .th(".nodeManagerVersion", "Version")._()._().tbody();
  NodeState stateFilter = null;
  if (type != null && !type.isEmpty()) {
    stateFilter = NodeState.valueOf(StringUtils.toUpperCase(type));
  }
  Collection<RMNode> rmNodes = this.rm.getRMContext().getRMNodes().values();
  boolean isInactive = false;
  if (stateFilter != null) {
    switch (stateFilter) {
    case DECOMMISSIONED:
    case LOST:
    case REBOOTED:
      rmNodes = this.rm.getRMContext().getInactiveRMNodes().values();
      isInactive = true;
      break;
    default:
      LOG.debug("Unexpected state filter for inactive RM node");
    }
  }
  for (RMNode ni : rmNodes) {
    if (stateFilter != null) {
      NodeState state = ni.getState();
      if (!stateFilter.equals(state)) {
        continue;
      }
    } else {
      // No filter. User is asking for all nodes. Make sure you skip the
      // unhealthy nodes.
      if (ni.getState() == NodeState.UNHEALTHY) {
        continue;
      }
    }
    // Besides state, we need to filter label as well.
    if (!labelFilter.equals(RMNodeLabelsManager.ANY)) {
      if (labelFilter.isEmpty()) {
        // Empty label filter means only shows nodes without label
        if (!ni.getNodeLabels().isEmpty()) {
          continue;
        }
      } else if (!ni.getNodeLabels().contains(labelFilter)) {
        // Only nodes have given label can show on web page.
        continue;
      }
    }
    NodeInfo info = new NodeInfo(ni, sched);
    int usedMemory = (int) info.getUsedMemory();
    int availableMemory = (int) info.getAvailableMemory();
    TR<TBODY<TABLE<Hamlet>>> row =
        tbody.tr().td(StringUtils.join(",", info.getNodeLabels()))
            .td(info.getRack()).td(info.getState()).td(info.getNodeId());
    if (isInactive) {
      row.td()._("N/A")._();
    } else {
      String httpAddress = info.getNodeHTTPAddress();
      row.td().a("//" + httpAddress, httpAddress)._();
    }
    row.td().br().$title(String.valueOf(info.getLastHealthUpdate()))._()
        ._(Times.format(info.getLastHealthUpdate()))._()
        .td(info.getHealthReport())
        .td(String.valueOf(info.getNumContainers())).td().br()
        .$title(String.valueOf(usedMemory))._()
        ._(StringUtils.byteDesc(usedMemory * BYTES_IN_MB))._().td().br()
        .$title(String.valueOf(availableMemory))._()
        ._(StringUtils.byteDesc(availableMemory * BYTES_IN_MB))._()
        .td(String.valueOf(info.getUsedVirtualCores()))
        .td(String.valueOf(info.getAvailableVirtualCores()))
        .td(String.valueOf(info.getUsedGpuCores()))
        .td(String.valueOf(info.getAvailableGpuCores()))
        .td(ni.getNodeManagerVersion())._();
  }
  tbody._()._();
}
 
Example 6
Source File: RMAppImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void processNodeUpdate(RMAppNodeUpdateType type, RMNode node) {
  NodeState nodeState = node.getState();
  updatedNodes.add(node);
  LOG.debug("Received node update event:" + type + " for node:" + node
      + " with state:" + nodeState);
}
 
Example 7
Source File: NodesPage.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void render(Block html) {
  html._(MetricsOverviewTable.class);

  ResourceScheduler sched = rm.getResourceScheduler();
  String type = $(NODE_STATE);
  String labelFilter = $(NODE_LABEL, CommonNodeLabelsManager.ANY).trim();
  TBODY<TABLE<Hamlet>> tbody =
      html.table("#nodes").thead().tr()
          .th(".nodelabels", "Node Labels")
          .th(".rack", "Rack")
          .th(".state", "Node State")
          .th(".nodeaddress", "Node Address")
          .th(".nodehttpaddress", "Node HTTP Address")
          .th(".lastHealthUpdate", "Last health-update")
          .th(".healthReport", "Health-report")
          .th(".containers", "Containers")
          .th(".mem", "Mem Used")
          .th(".mem", "Mem Avail")
          .th(".vcores", "VCores Used")
          .th(".vcores", "VCores Avail")
          .th(".nodeManagerVersion", "Version")._()._().tbody();
  NodeState stateFilter = null;
  if (type != null && !type.isEmpty()) {
    stateFilter = NodeState.valueOf(StringUtils.toUpperCase(type));
  }
  Collection<RMNode> rmNodes = this.rm.getRMContext().getRMNodes().values();
  boolean isInactive = false;
  if (stateFilter != null) {
    switch (stateFilter) {
    case DECOMMISSIONED:
    case LOST:
    case REBOOTED:
      rmNodes = this.rm.getRMContext().getInactiveRMNodes().values();
      isInactive = true;
      break;
    default:
      LOG.debug("Unexpected state filter for inactive RM node");
    }
  }
  for (RMNode ni : rmNodes) {
    if (stateFilter != null) {
      NodeState state = ni.getState();
      if (!stateFilter.equals(state)) {
        continue;
      }
    } else {
      // No filter. User is asking for all nodes. Make sure you skip the
      // unhealthy nodes.
      if (ni.getState() == NodeState.UNHEALTHY) {
        continue;
      }
    }
    // Besides state, we need to filter label as well.
    if (!labelFilter.equals(RMNodeLabelsManager.ANY)) {
      if (labelFilter.isEmpty()) {
        // Empty label filter means only shows nodes without label
        if (!ni.getNodeLabels().isEmpty()) {
          continue;
        }
      } else if (!ni.getNodeLabels().contains(labelFilter)) {
        // Only nodes have given label can show on web page.
        continue;
      }
    }
    NodeInfo info = new NodeInfo(ni, sched);
    int usedMemory = (int) info.getUsedMemory();
    int availableMemory = (int) info.getAvailableMemory();
    TR<TBODY<TABLE<Hamlet>>> row =
        tbody.tr().td(StringUtils.join(",", info.getNodeLabels()))
            .td(info.getRack()).td(info.getState()).td(info.getNodeId());
    if (isInactive) {
      row.td()._("N/A")._();
    } else {
      String httpAddress = info.getNodeHTTPAddress();
      row.td().a("//" + httpAddress, httpAddress)._();
    }
    row.td().br().$title(String.valueOf(info.getLastHealthUpdate()))._()
        ._(Times.format(info.getLastHealthUpdate()))._()
        .td(info.getHealthReport())
        .td(String.valueOf(info.getNumContainers())).td().br()
        .$title(String.valueOf(usedMemory))._()
        ._(StringUtils.byteDesc(usedMemory * BYTES_IN_MB))._().td().br()
        .$title(String.valueOf(availableMemory))._()
        ._(StringUtils.byteDesc(availableMemory * BYTES_IN_MB))._()
        .td(String.valueOf(info.getUsedVirtualCores()))
        .td(String.valueOf(info.getAvailableVirtualCores()))
        .td(ni.getNodeManagerVersion())._();
  }
  tbody._()._();
}
 
Example 8
Source File: RMAppImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void processNodeUpdate(RMAppNodeUpdateType type, RMNode node) {
  NodeState nodeState = node.getState();
  updatedNodes.add(node);
  LOG.debug("Received node update event:" + type + " for node:" + node
      + " with state:" + nodeState);
}