Java Code Examples for org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler#getNodeReport()

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler#getNodeReport() . These examples are extracted from open source projects. 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 Project: hadoop   File: NodeInfo.java    License: 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 2
Source Project: big-c   File: NodeInfo.java    License: 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 3
Source Project: hadoop   File: TestRMWebServicesNodes.java    License: Apache License 2.0 4 votes vote down vote up
public void verifyNodeInfoGeneric(MockNM nm, String state, String rack,
    String id, String nodeHostName,
    String nodeHTTPAddress, long lastHealthUpdate, String healthReport,
    int numContainers, long usedMemoryMB, long availMemoryMB, long usedVirtualCores, 
    long availVirtualCores, long usedGpuCores, long availGpuCores, String version)
    throws JSONException, Exception {

  RMNode node = rm.getRMContext().getRMNodes().get(nm.getNodeId());
  ResourceScheduler sched = rm.getResourceScheduler();
  SchedulerNodeReport report = sched.getNodeReport(nm.getNodeId());

  WebServicesTestUtils.checkStringMatch("state", node.getState().toString(),
      state);
  WebServicesTestUtils.checkStringMatch("rack", node.getRackName(), rack);
  WebServicesTestUtils.checkStringMatch("id", nm.getNodeId().toString(), id);
  WebServicesTestUtils.checkStringMatch("nodeHostName", nm.getNodeId()
      .getHost(), nodeHostName);
  WebServicesTestUtils.checkStringMatch("healthReport",
      String.valueOf(node.getHealthReport()), healthReport);
  String expectedHttpAddress = nm.getNodeId().getHost() + ":"
      + nm.getHttpPort();
  WebServicesTestUtils.checkStringMatch("nodeHTTPAddress",
      expectedHttpAddress, nodeHTTPAddress);
  WebServicesTestUtils.checkStringMatch("version",
      node.getNodeManagerVersion(), version);

  long expectedHealthUpdate = node.getLastHealthReportTime();
  assertEquals("lastHealthUpdate doesn't match, got: " + lastHealthUpdate
      + " expected: " + expectedHealthUpdate, expectedHealthUpdate,
      lastHealthUpdate);

  if (report != null) {
    assertEquals("numContainers doesn't match: " + numContainers,
        report.getNumContainers(), numContainers);
    assertEquals("usedMemoryMB doesn't match: " + usedMemoryMB, report
        .getUsedResource().getMemory(), usedMemoryMB);
    assertEquals("availMemoryMB doesn't match: " + availMemoryMB, report
        .getAvailableResource().getMemory(), availMemoryMB);
    assertEquals("usedVirtualCores doesn't match: " + usedVirtualCores, report
        .getUsedResource().getVirtualCores(), usedVirtualCores);
    assertEquals("availVirtualCores doesn't match: " + availVirtualCores, report
        .getAvailableResource().getVirtualCores(), availVirtualCores);
    assertEquals("usedGpuCores doesn't match: " + usedGpuCores, report
        .getUsedResource().getGpuCores(), usedGpuCores);
    assertEquals("availGpuCores doesn't match: " + availGpuCores, report
        .getAvailableResource().getGpuCores(), availGpuCores);
  }
}
 
Example 4
Source Project: big-c   File: TestRMWebServicesNodes.java    License: Apache License 2.0 4 votes vote down vote up
public void verifyNodeInfoGeneric(MockNM nm, String state, String rack,
    String id, String nodeHostName,
    String nodeHTTPAddress, long lastHealthUpdate, String healthReport,
    int numContainers, long usedMemoryMB, long availMemoryMB, long usedVirtualCores, 
    long availVirtualCores, String version)
    throws JSONException, Exception {

  RMNode node = rm.getRMContext().getRMNodes().get(nm.getNodeId());
  ResourceScheduler sched = rm.getResourceScheduler();
  SchedulerNodeReport report = sched.getNodeReport(nm.getNodeId());

  WebServicesTestUtils.checkStringMatch("state", node.getState().toString(),
      state);
  WebServicesTestUtils.checkStringMatch("rack", node.getRackName(), rack);
  WebServicesTestUtils.checkStringMatch("id", nm.getNodeId().toString(), id);
  WebServicesTestUtils.checkStringMatch("nodeHostName", nm.getNodeId()
      .getHost(), nodeHostName);
  WebServicesTestUtils.checkStringMatch("healthReport",
      String.valueOf(node.getHealthReport()), healthReport);
  String expectedHttpAddress = nm.getNodeId().getHost() + ":"
      + nm.getHttpPort();
  WebServicesTestUtils.checkStringMatch("nodeHTTPAddress",
      expectedHttpAddress, nodeHTTPAddress);
  WebServicesTestUtils.checkStringMatch("version",
      node.getNodeManagerVersion(), version);

  long expectedHealthUpdate = node.getLastHealthReportTime();
  assertEquals("lastHealthUpdate doesn't match, got: " + lastHealthUpdate
      + " expected: " + expectedHealthUpdate, expectedHealthUpdate,
      lastHealthUpdate);

  if (report != null) {
    assertEquals("numContainers doesn't match: " + numContainers,
        report.getNumContainers(), numContainers);
    assertEquals("usedMemoryMB doesn't match: " + usedMemoryMB, report
        .getUsedResource().getMemory(), usedMemoryMB);
    assertEquals("availMemoryMB doesn't match: " + availMemoryMB, report
        .getAvailableResource().getMemory(), availMemoryMB);
    assertEquals("usedVirtualCores doesn't match: " + usedVirtualCores, report
        .getUsedResource().getVirtualCores(), usedVirtualCores);
    assertEquals("availVirtualCores doesn't match: " + availVirtualCores, report
        .getAvailableResource().getVirtualCores(), availVirtualCores);
  }
}