use of org.apache.hadoop.yarn.server.api.protocolrecords.RemoteNode in project hadoop by apache.
the class OpportunisticContainerAllocator method allocateContainersInternal.
private void allocateContainersInternal(long rmIdentifier, AllocationParams appParams, ContainerIdGenerator idCounter, Set<String> blacklist, ApplicationAttemptId id, Map<String, RemoteNode> allNodes, String userName, Map<Resource, List<Container>> containers, ResourceRequest anyAsk) throws YarnException {
int toAllocate = anyAsk.getNumContainers() - (containers.isEmpty() ? 0 : containers.get(anyAsk.getCapability()).size());
List<RemoteNode> nodesForScheduling = new ArrayList<>();
for (Entry<String, RemoteNode> nodeEntry : allNodes.entrySet()) {
// Do not use blacklisted nodes for scheduling.
if (blacklist.contains(nodeEntry.getKey())) {
continue;
}
nodesForScheduling.add(nodeEntry.getValue());
}
if (nodesForScheduling.isEmpty()) {
LOG.warn("No nodes available for allocating opportunistic containers. [" + "allNodes=" + allNodes + ", " + "blacklist=" + blacklist + "]");
return;
}
int numAllocated = 0;
int nextNodeToSchedule = 0;
for (int numCont = 0; numCont < toAllocate; numCont++) {
nextNodeToSchedule++;
nextNodeToSchedule %= nodesForScheduling.size();
RemoteNode node = nodesForScheduling.get(nextNodeToSchedule);
Container container = buildContainer(rmIdentifier, appParams, idCounter, anyAsk, id, userName, node);
List<Container> cList = containers.get(anyAsk.getCapability());
if (cList == null) {
cList = new ArrayList<>();
containers.put(anyAsk.getCapability(), cList);
}
cList.add(container);
numAllocated++;
LOG.info("Allocated [" + container.getId() + "] as opportunistic.");
}
LOG.info("Allocated " + numAllocated + " opportunistic containers.");
}
use of org.apache.hadoop.yarn.server.api.protocolrecords.RemoteNode in project hadoop by apache.
the class OpportunisticContainerContext method updateNodeList.
public synchronized void updateNodeList(List<RemoteNode> newNodeList) {
// modified.
if (newNodeList != nodeList) {
nodeList = newNodeList;
nodeMap.clear();
for (RemoteNode n : nodeList) {
nodeMap.put(n.getNodeId().getHost(), n);
}
}
}
Aggregations