Java Code Examples for org.apache.hadoop.yarn.server.api.records.NodeHealthStatus#setIsNodeHealthy()

The following examples show how to use org.apache.hadoop.yarn.server.api.records.NodeHealthStatus#setIsNodeHealthy() . 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: NodeStatusUpdaterImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private NodeStatus getNodeStatus(int responseId) throws IOException {

    NodeHealthStatus nodeHealthStatus = this.context.getNodeHealthStatus();
    nodeHealthStatus.setHealthReport(healthChecker.getHealthReport());
    nodeHealthStatus.setIsNodeHealthy(healthChecker.isHealthy());
    nodeHealthStatus.setLastHealthReportTime(healthChecker
      .getLastHealthReportTime());
    if (LOG.isDebugEnabled()) {
      LOG.debug("Node's health-status : " + nodeHealthStatus.getIsNodeHealthy()
          + ", " + nodeHealthStatus.getHealthReport());
    }
    List<ContainerStatus> containersStatuses = getContainerStatuses();
    NodeStatus nodeStatus =
        NodeStatus.newInstance(nodeId, responseId, containersStatuses,
          createKeepAliveApplicationList(), nodeHealthStatus);

    return nodeStatus;
  }
 
Example 2
Source File: NodeStatusUpdaterImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
private NodeStatus getNodeStatus(int responseId) throws IOException {

    NodeHealthStatus nodeHealthStatus = this.context.getNodeHealthStatus();
    nodeHealthStatus.setHealthReport(healthChecker.getHealthReport());
    nodeHealthStatus.setIsNodeHealthy(healthChecker.isHealthy());
    nodeHealthStatus.setLastHealthReportTime(healthChecker
      .getLastHealthReportTime());
    if (LOG.isDebugEnabled()) {
      LOG.debug("Node's health-status : " + nodeHealthStatus.getIsNodeHealthy()
          + ", " + nodeHealthStatus.getHealthReport());
    }
    List<ContainerStatus> containersStatuses = getContainerStatuses();
    NodeStatus nodeStatus =
        NodeStatus.newInstance(nodeId, responseId, containersStatuses,
          createKeepAliveApplicationList(), nodeHealthStatus);

    return nodeStatus;
  }
 
Example 3
Source File: TestYarnServerApiClasses.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private NodeHealthStatus getNodeHealthStatus() {
  NodeHealthStatus healStatus = recordFactory
      .newRecordInstance(NodeHealthStatus.class);
  healStatus.setHealthReport("healthReport");
  healStatus.setIsNodeHealthy(true);
  healStatus.setLastHealthReportTime(1000);
  return healStatus;

}
 
Example 4
Source File: NodeManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static org.apache.hadoop.yarn.server.api.records.NodeStatus 
createNodeStatus(NodeId nodeId, List<ContainerStatus> containers) {
  RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
  org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = 
      recordFactory.newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class);
  nodeStatus.setNodeId(nodeId);
  nodeStatus.setContainersStatuses(containers);
  NodeHealthStatus nodeHealthStatus = 
    recordFactory.newRecordInstance(NodeHealthStatus.class);
  nodeHealthStatus.setIsNodeHealthy(true);
  nodeStatus.setNodeHealthStatus(nodeHealthStatus);
  return nodeStatus;
}
 
Example 5
Source File: MockNM.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public NodeHeartbeatResponse nodeHeartbeat(Map<ApplicationId,
    List<ContainerStatus>> conts, boolean isHealthy, int resId) throws Exception {
  NodeHeartbeatRequest req = Records.newRecord(NodeHeartbeatRequest.class);
  NodeStatus status = Records.newRecord(NodeStatus.class);
  status.setResponseId(resId);
  status.setNodeId(nodeId);
  for (Map.Entry<ApplicationId, List<ContainerStatus>> entry : conts.entrySet()) {
    Log.info("entry.getValue() " + entry.getValue());
    status.setContainersStatuses(entry.getValue());
  }
  NodeHealthStatus healthStatus = Records.newRecord(NodeHealthStatus.class);
  healthStatus.setHealthReport("");
  healthStatus.setIsNodeHealthy(isHealthy);
  healthStatus.setLastHealthReportTime(1);
  status.setNodeHealthStatus(healthStatus);
  req.setNodeStatus(status);
  req.setLastKnownContainerTokenMasterKey(this.currentContainerTokenMasterKey);
  req.setLastKnownNMTokenMasterKey(this.currentNMTokenMasterKey);
  NodeHeartbeatResponse heartbeatResponse =
      resourceTracker.nodeHeartbeat(req);
  
  MasterKey masterKeyFromRM = heartbeatResponse.getContainerTokenMasterKey();
  if (masterKeyFromRM != null
      && masterKeyFromRM.getKeyId() != this.currentContainerTokenMasterKey
          .getKeyId()) {
    this.currentContainerTokenMasterKey = masterKeyFromRM;
  }

  masterKeyFromRM = heartbeatResponse.getNMTokenMasterKey();
  if (masterKeyFromRM != null
      && masterKeyFromRM.getKeyId() != this.currentNMTokenMasterKey
          .getKeyId()) {
    this.currentNMTokenMasterKey = masterKeyFromRM;
  }
  
  return heartbeatResponse;
}
 
Example 6
Source File: TestYarnServerApiClasses.java    From big-c with Apache License 2.0 5 votes vote down vote up
private NodeHealthStatus getNodeHealthStatus() {
  NodeHealthStatus healStatus = recordFactory
      .newRecordInstance(NodeHealthStatus.class);
  healStatus.setHealthReport("healthReport");
  healStatus.setIsNodeHealthy(true);
  healStatus.setLastHealthReportTime(1000);
  return healStatus;

}
 
Example 7
Source File: NodeManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static org.apache.hadoop.yarn.server.api.records.NodeStatus 
createNodeStatus(NodeId nodeId, List<ContainerStatus> containers) {
  RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
  org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = 
      recordFactory.newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class);
  nodeStatus.setNodeId(nodeId);
  nodeStatus.setContainersStatuses(containers);
  NodeHealthStatus nodeHealthStatus = 
    recordFactory.newRecordInstance(NodeHealthStatus.class);
  nodeHealthStatus.setIsNodeHealthy(true);
  nodeStatus.setNodeHealthStatus(nodeHealthStatus);
  return nodeStatus;
}
 
Example 8
Source File: MockNM.java    From big-c with Apache License 2.0 5 votes vote down vote up
public NodeHeartbeatResponse nodeHeartbeat(Map<ApplicationId,
    List<ContainerStatus>> conts, boolean isHealthy, int resId) throws Exception {
  NodeHeartbeatRequest req = Records.newRecord(NodeHeartbeatRequest.class);
  NodeStatus status = Records.newRecord(NodeStatus.class);
  status.setResponseId(resId);
  status.setNodeId(nodeId);
  for (Map.Entry<ApplicationId, List<ContainerStatus>> entry : conts.entrySet()) {
    Log.info("entry.getValue() " + entry.getValue());
    status.setContainersStatuses(entry.getValue());
  }
  NodeHealthStatus healthStatus = Records.newRecord(NodeHealthStatus.class);
  healthStatus.setHealthReport("");
  healthStatus.setIsNodeHealthy(isHealthy);
  healthStatus.setLastHealthReportTime(1);
  status.setNodeHealthStatus(healthStatus);
  req.setNodeStatus(status);
  req.setLastKnownContainerTokenMasterKey(this.currentContainerTokenMasterKey);
  req.setLastKnownNMTokenMasterKey(this.currentNMTokenMasterKey);
  NodeHeartbeatResponse heartbeatResponse =
      resourceTracker.nodeHeartbeat(req);
  
  MasterKey masterKeyFromRM = heartbeatResponse.getContainerTokenMasterKey();
  if (masterKeyFromRM != null
      && masterKeyFromRM.getKeyId() != this.currentContainerTokenMasterKey
          .getKeyId()) {
    this.currentContainerTokenMasterKey = masterKeyFromRM;
  }

  masterKeyFromRM = heartbeatResponse.getNMTokenMasterKey();
  if (masterKeyFromRM != null
      && masterKeyFromRM.getKeyId() != this.currentNMTokenMasterKey
          .getKeyId()) {
    this.currentNMTokenMasterKey = masterKeyFromRM;
  }
  
  return heartbeatResponse;
}
 
Example 9
Source File: TestNodeHealthService.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void setHealthStatus(NodeHealthStatus healthStatus, boolean isHealthy,
    String healthReport, long lastHealthReportTime) {
  healthStatus.setHealthReport(healthReport);
  healthStatus.setIsNodeHealthy(isHealthy);
  healthStatus.setLastHealthReportTime(lastHealthReportTime);
}
 
Example 10
Source File: TestRMNMRPCResponseId.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testRPCResponseId() throws IOException, YarnException {
  String node = "localhost";
  Resource capability = BuilderUtils.newResource(1024, 1, 1);
  RegisterNodeManagerRequest request = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
  nodeId = NodeId.newInstance(node, 1234);
  request.setNodeId(nodeId);
  request.setHttpPort(0);
  request.setResource(capability);

  RegisterNodeManagerRequest request1 = recordFactory
      .newRecordInstance(RegisterNodeManagerRequest.class);
  request1.setNodeId(nodeId);
  request1.setHttpPort(0);
  request1.setResource(capability);
  resourceTrackerService.registerNodeManager(request1);

  org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory.
    newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class);
  nodeStatus.setNodeId(nodeId);
  NodeHealthStatus nodeHealthStatus = recordFactory.newRecordInstance(NodeHealthStatus.class);
  nodeHealthStatus.setIsNodeHealthy(true);
  nodeStatus.setNodeHealthStatus(nodeHealthStatus);
  NodeHeartbeatRequest nodeHeartBeatRequest = recordFactory
      .newRecordInstance(NodeHeartbeatRequest.class);
  nodeHeartBeatRequest.setNodeStatus(nodeStatus);

  nodeStatus.setResponseId(0);
  NodeHeartbeatResponse response = resourceTrackerService.nodeHeartbeat(
      nodeHeartBeatRequest);
  Assert.assertTrue(response.getResponseId() == 1);

  nodeStatus.setResponseId(response.getResponseId());
  response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest);
  Assert.assertTrue(response.getResponseId() == 2);   

  /* try calling with less response id */
  response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest);
  Assert.assertTrue(response.getResponseId() == 2);

  nodeStatus.setResponseId(0);
  response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest);
  Assert.assertTrue(NodeAction.RESYNC.equals(response.getNodeAction()));
  Assert.assertEquals("Too far behind rm response id:2 nm response id:0",
    response.getDiagnosticsMessage());
}
 
Example 11
Source File: TestNodeHealthService.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void setHealthStatus(NodeHealthStatus healthStatus, boolean isHealthy,
    String healthReport, long lastHealthReportTime) {
  healthStatus.setHealthReport(healthReport);
  healthStatus.setIsNodeHealthy(isHealthy);
  healthStatus.setLastHealthReportTime(lastHealthReportTime);
}
 
Example 12
Source File: TestRMNMRPCResponseId.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testRPCResponseId() throws IOException, YarnException {
  String node = "localhost";
  Resource capability = BuilderUtils.newResource(1024, 1);
  RegisterNodeManagerRequest request = recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
  nodeId = NodeId.newInstance(node, 1234);
  request.setNodeId(nodeId);
  request.setHttpPort(0);
  request.setResource(capability);

  RegisterNodeManagerRequest request1 = recordFactory
      .newRecordInstance(RegisterNodeManagerRequest.class);
  request1.setNodeId(nodeId);
  request1.setHttpPort(0);
  request1.setResource(capability);
  resourceTrackerService.registerNodeManager(request1);

  org.apache.hadoop.yarn.server.api.records.NodeStatus nodeStatus = recordFactory.
    newRecordInstance(org.apache.hadoop.yarn.server.api.records.NodeStatus.class);
  nodeStatus.setNodeId(nodeId);
  NodeHealthStatus nodeHealthStatus = recordFactory.newRecordInstance(NodeHealthStatus.class);
  nodeHealthStatus.setIsNodeHealthy(true);
  nodeStatus.setNodeHealthStatus(nodeHealthStatus);
  NodeHeartbeatRequest nodeHeartBeatRequest = recordFactory
      .newRecordInstance(NodeHeartbeatRequest.class);
  nodeHeartBeatRequest.setNodeStatus(nodeStatus);

  nodeStatus.setResponseId(0);
  NodeHeartbeatResponse response = resourceTrackerService.nodeHeartbeat(
      nodeHeartBeatRequest);
  Assert.assertTrue(response.getResponseId() == 1);

  nodeStatus.setResponseId(response.getResponseId());
  response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest);
  Assert.assertTrue(response.getResponseId() == 2);   

  /* try calling with less response id */
  response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest);
  Assert.assertTrue(response.getResponseId() == 2);

  nodeStatus.setResponseId(0);
  response = resourceTrackerService.nodeHeartbeat(nodeHeartBeatRequest);
  Assert.assertTrue(NodeAction.RESYNC.equals(response.getNodeAction()));
  Assert.assertEquals("Too far behind rm response id:2 nm response id:0",
    response.getDiagnosticsMessage());
}