Java Code Examples for org.apache.hadoop.yarn.api.records.NodeId#getHost()

The following examples show how to use org.apache.hadoop.yarn.api.records.NodeId#getHost() . 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: YarnNodeCapacityManager.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Override
public void afterSchedulerEventHandled(SchedulerEvent event) {
  switch (event.getType()) {
    case NODE_ADDED:
      if (!(event instanceof NodeAddedSchedulerEvent)) {
        LOGGER.error("{} not an instance of {}", event.getClass().getName(), NodeAddedSchedulerEvent.class.getName());
        return;
      }

      NodeAddedSchedulerEvent nodeAddedEvent = (NodeAddedSchedulerEvent) event;
      NodeId nodeId = nodeAddedEvent.getAddedRMNode().getNodeID();
      String host = nodeId.getHost();

      SchedulerNode node = yarnScheduler.getSchedulerNode(nodeId);
      nodeStore.add(node);
      LOGGER.info("afterSchedulerEventHandled: NM registration from node {}", host);
      break;

    case NODE_UPDATE:
      if (!(event instanceof NodeUpdateSchedulerEvent)) {
        LOGGER.error("{} not an instance of {}", event.getClass().getName(), NodeUpdateSchedulerEvent.class.getName());
        return;
      }

      RMNode rmNode = ((NodeUpdateSchedulerEvent) event).getRMNode();
      handleContainerAllocation(rmNode);

      break;

    default:
      break;
  }
}
 
Example 2
Source File: AMNodeMap.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
private void addToBlackList(NodeId nodeId) {
  String host = nodeId.getHost();
  Set<NodeId> nodes;
  
  if (!blacklistMap.containsKey(host)) {
    nodes = new HashSet<NodeId>();
    blacklistMap.put(host, nodes);
  } else {
    nodes = blacklistMap.get(host);
  }
  
  if (!nodes.contains(nodeId)) {
    nodes.add(nodeId);
  }
}
 
Example 3
Source File: PerSourceNodeTracker.java    From tez with Apache License 2.0 5 votes vote down vote up
private void addToBlackList(NodeId nodeId) {
  String host = nodeId.getHost();

  if (!blacklistMap.containsKey(host)) {
    blacklistMap.putIfAbsent(host, new HashSet<NodeId>());
  }
  Set<NodeId> nodes = blacklistMap.get(host);

  if (!nodes.contains(nodeId)) {
    nodes.add(nodeId);
  }
}
 
Example 4
Source File: TestAMNodeTracker.java    From tez with Apache License 2.0 5 votes vote down vote up
private static NodeReport generateNodeReport(NodeId nodeId, NodeState nodeState) {
  NodeReport nodeReport = mock(NodeReport.class);
  doReturn(nodeId).when(nodeReport).getNodeId();
  doReturn(nodeState).when(nodeReport).getNodeState();
  String httpAddress = nodeId.getHost() + ":3433";
  doReturn(httpAddress).when(nodeReport).getHttpAddress();
  doReturn("/default-rack").when(nodeReport).getRackName();
  doReturn(Resource.newInstance(0, 0)).when(nodeReport).getUsed();
  doReturn(Resource.newInstance(10240, 12)).when(nodeReport).getCapability();
  doReturn(10).when(nodeReport).getNumContainers();
  doReturn(nodeState.toString()).when(nodeReport).getHealthReport();
  long healthReportTime = System.currentTimeMillis();
  doReturn(healthReportTime).when(nodeReport).getLastHealthReportTime();
  return nodeReport;
}
 
Example 5
Source File: TestObjectFactory.java    From incubator-myriad with Apache License 2.0 4 votes vote down vote up
public static RMNode getRMNode(String host, int port, Resource resource) {
  NodeId id = NodeId.newInstance(host, port);
  RMContext context = new MockRMContext();
  return new RMNodeImpl(id, context, id.getHost(), id.getPort(), id.getPort(), new NodeBase(host, "/tmp"), resource, "version-one");
}