List of usage examples for org.apache.hadoop.yarn.server.resourcemanager.scheduler SchedulerNode getNodeID
public NodeId getNodeID()
From source file:org.apache.myriad.policy.LeastAMNodesFirstPolicy.java
License:Apache License
/** * Sort the given list of tasks by the number of App Master containers running on the corresponding NM node. * * @param taskIDs/* ww w. j av a2 s .c o m*/ */ @Override public void apply(List<Protos.TaskID> taskIDs) { if (LOGGER.isDebugEnabled()) { for (SchedulerNode node : schedulerNodes.values()) { LOGGER.debug("Host {} is running {} containers including {} App Masters", node.getNodeID().getHost(), node.getRunningContainers().size(), getNumAMContainers(node.getRunningContainers())); } } // We need to lock the YARN scheduler here. If we don't do that, then the YARN scheduler can // process HBs from NodeManagers and the state of SchedulerNode objects might change while we // are in the middle of sorting them based on the least number of AM containers. synchronized (yarnScheduler) { Collections.sort(taskIDs, new Comparator<Protos.TaskID>() { @Override public int compare(Protos.TaskID t1, Protos.TaskID t2) { SchedulerNode o1 = schedulerNodes.get(schedulerState.getTask(t1).getHostname()); SchedulerNode o2 = schedulerNodes.get(schedulerState.getTask(t2).getHostname()); if (o1 == null) { // a NM was launched by Myriad, but it hasn't yet registered with RM if (o2 == null) { return 0; } else { return -1; } } else if (o2 == null) { return 1; } // else, both the NMs have registered with RM List<RMContainer> runningContainers1 = o1.getRunningContainers(); List<RMContainer> runningContainers2 = o2.getRunningContainers(); Integer numRunningAMs1 = getNumAMContainers(runningContainers1); Integer numRunningAMs2 = getNumAMContainers(runningContainers2); Integer numRunningContainers1 = runningContainers1.size(); Integer numRunningContainers2 = runningContainers2.size(); // If two NMs are running equal number of AMs, sort them based on total num of running containers if (numRunningAMs1.compareTo(numRunningAMs2) == 0) { return numRunningContainers1.compareTo(numRunningContainers2); } return numRunningAMs1.compareTo(numRunningAMs2); } }); } }
From source file:org.apache.myriad.policy.LeastAMNodesFirstPolicy.java
License:Apache License
private void onNodeRemoved(NodeRemovedSchedulerEvent event) { SchedulerNode schedulerNode = schedulerNodes.get(event.getRemovedRMNode().getNodeID().getHost()); if (schedulerNode != null && schedulerNode.getNodeID().equals(event.getRemovedRMNode().getNodeID())) { schedulerNodes.remove(schedulerNode.getNodeID().getHost()); }/*from w ww . j a v a 2 s . c om*/ }
From source file:org.apache.myriad.scheduler.fgs.NodeStore.java
License:Apache License
private String getKey(SchedulerNode schedNode) { return schedNode.getNodeID().getHost(); }