use of org.apache.hadoop.yarn.api.records.ResourceUtilization in project hadoop by apache.
the class NodeStatusUpdaterImpl method getNodeStatus.
@VisibleForTesting
protected 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();
ResourceUtilization containersUtilization = getContainersUtilization();
ResourceUtilization nodeUtilization = getNodeUtilization();
List<org.apache.hadoop.yarn.api.records.Container> increasedContainers = getIncreasedContainers();
NodeStatus nodeStatus = NodeStatus.newInstance(nodeId, responseId, containersStatuses, createKeepAliveApplicationList(), nodeHealthStatus, containersUtilization, nodeUtilization, increasedContainers);
nodeStatus.setOpportunisticContainersStatus(getOpportunisticContainersStatus());
return nodeStatus;
}
use of org.apache.hadoop.yarn.api.records.ResourceUtilization in project hadoop by apache.
the class ContainerScheduler method pickOpportunisticContainersToKill.
private List<Container> pickOpportunisticContainersToKill(ContainerId containerToStartId) {
// The opportunistic containers that need to be killed for the
// given container to start.
List<Container> extraOpportContainersToKill = new ArrayList<>();
// Track resources that need to be freed.
ResourceUtilization resourcesToFreeUp = resourcesToFreeUp(containerToStartId);
// Go over the running opportunistic containers.
// Use a descending iterator to kill more recently started containers.
Iterator<Container> lifoIterator = new LinkedList<>(runningContainers.values()).descendingIterator();
while (lifoIterator.hasNext() && !hasSufficientResources(resourcesToFreeUp)) {
Container runningCont = lifoIterator.next();
if (runningCont.getContainerTokenIdentifier().getExecutionType() == ExecutionType.OPPORTUNISTIC) {
if (oppContainersToKill.containsKey(runningCont.getContainerId())) {
// So exclude them..
continue;
}
extraOpportContainersToKill.add(runningCont);
ContainersMonitor.decreaseResourceUtilization(getContainersMonitor(), resourcesToFreeUp, runningCont.getResource());
}
}
if (!hasSufficientResources(resourcesToFreeUp)) {
LOG.warn("There are no sufficient resources to start guaranteed [{}]" + "at the moment. Opportunistic containers are in the process of" + "being killed to make room.", containerToStartId);
}
return extraOpportContainersToKill;
}
use of org.apache.hadoop.yarn.api.records.ResourceUtilization in project hadoop by apache.
the class ContainerScheduler method resourcesToFreeUp.
private ResourceUtilization resourcesToFreeUp(ContainerId containerToStartId) {
// Get allocation of currently allocated containers.
ResourceUtilization resourceAllocationToFreeUp = ResourceUtilization.newInstance(this.utilizationTracker.getCurrentUtilization());
// containers that will start before the current container will be started.
for (Container container : queuedGuaranteedContainers.values()) {
ContainersMonitor.increaseResourceUtilization(getContainersMonitor(), resourceAllocationToFreeUp, container.getResource());
if (container.getContainerId().equals(containerToStartId)) {
break;
}
}
// guaranteed container..
for (Container container : oppContainersToKill.values()) {
ContainersMonitor.decreaseResourceUtilization(getContainersMonitor(), resourceAllocationToFreeUp, container.getResource());
}
// Subtract the overall node resources.
getContainersMonitor().subtractNodeResourcesFromResourceUtilization(resourceAllocationToFreeUp);
return resourceAllocationToFreeUp;
}
Aggregations