Search in sources :

Example 6 with ResourceUtilization

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;
}
Also used : NMContainerStatus(org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus) ContainerStatus(org.apache.hadoop.yarn.api.records.ContainerStatus) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ResourceUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization) NodeStatus(org.apache.hadoop.yarn.server.api.records.NodeStatus) NodeHealthStatus(org.apache.hadoop.yarn.server.api.records.NodeHealthStatus) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with ResourceUtilization

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;
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ArrayList(java.util.ArrayList) ResourceUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization)

Example 8 with ResourceUtilization

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;
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ResourceUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization)

Aggregations

ResourceUtilization (org.apache.hadoop.yarn.api.records.ResourceUtilization)8 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)3 NodeStatus (org.apache.hadoop.yarn.server.api.records.NodeStatus)3 Container (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)3 ArrayList (java.util.ArrayList)2 NodeHealthStatus (org.apache.hadoop.yarn.server.api.records.NodeHealthStatus)2 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 WebResource (com.sun.jersey.api.client.WebResource)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 NodeReport (org.apache.hadoop.yarn.api.records.NodeReport)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 NMContainerStatus (org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus)1 OpportunisticContainersStatus (org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus)1 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)1 ResourceManager (org.apache.hadoop.yarn.server.resourcemanager.ResourceManager)1 RMNodeImpl (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeImpl)1 RMNodeStatusEvent (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeStatusEvent)1 ResourceScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler)1