Search in sources :

Example 41 with RMContainer

use of org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer in project hadoop by apache.

the class PreemptableQueue method addKillableContainer.

void addKillableContainer(KillableContainer container) {
    String partition = container.getNodePartition();
    if (!totalKillableResources.containsKey(partition)) {
        totalKillableResources.put(partition, Resources.createResource(0));
        killableContainers.put(partition, new ConcurrentSkipListMap<ContainerId, RMContainer>());
    }
    RMContainer c = container.getRMContainer();
    Resources.addTo(totalKillableResources.get(partition), c.getAllocatedResource());
    killableContainers.get(partition).put(c.getContainerId(), c);
    if (null != parent) {
        parent.addKillableContainer(container);
    }
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Example 42 with RMContainer

use of org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer in project hadoop by apache.

the class PreemptableQueue method removeKillableContainer.

void removeKillableContainer(KillableContainer container) {
    String partition = container.getNodePartition();
    Map<ContainerId, RMContainer> partitionKillableContainers = killableContainers.get(partition);
    if (partitionKillableContainers != null) {
        RMContainer rmContainer = partitionKillableContainers.remove(container.getRMContainer().getContainerId());
        if (null != rmContainer) {
            Resources.subtractFrom(totalKillableResources.get(partition), rmContainer.getAllocatedResource());
        }
    }
    if (null != parent) {
        parent.removeKillableContainer(container);
    }
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Example 43 with RMContainer

use of org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer in project hadoop by apache.

the class AssignmentInformation method getFirstAllocatedOrReservedRMContainer.

public RMContainer getFirstAllocatedOrReservedRMContainer() {
    RMContainer rmContainer;
    rmContainer = getFirstRMContainerFromOperation(Operation.ALLOCATION);
    if (null != rmContainer) {
        return rmContainer;
    }
    return getFirstRMContainerFromOperation(Operation.RESERVATION);
}
Also used : RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Example 44 with RMContainer

use of org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer in project hadoop by apache.

the class FiCaSchedulerApp method commonCheckContainerAllocation.

private boolean commonCheckContainerAllocation(Resource cluster, ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> allocation, SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> schedulerContainer) {
    // Make sure node is not reserved by anyone else
    RMContainer reservedContainerOnNode = schedulerContainer.getSchedulerNode().getReservedContainer();
    if (reservedContainerOnNode != null) {
        RMContainer fromReservedContainer = allocation.getAllocateFromReservedContainer().getRmContainer();
        if (fromReservedContainer != reservedContainerOnNode) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Try to allocate from a non-existed reserved container");
            }
            return false;
        }
    }
    // Do we have enough space on this node?
    Resource availableResource = Resources.clone(schedulerContainer.getSchedulerNode().getUnallocatedResource());
    // of this node
    if (allocation.getToRelease() != null && !allocation.getToRelease().isEmpty()) {
        for (SchedulerContainer<FiCaSchedulerApp, FiCaSchedulerNode> releaseContainer : allocation.getToRelease()) {
            // not affect available resource of node) on the same node
            if (releaseContainer.getRmContainer().getState() != RMContainerState.RESERVED && releaseContainer.getSchedulerNode() == schedulerContainer.getSchedulerNode()) {
                Resources.addTo(availableResource, releaseContainer.getRmContainer().getAllocatedResource());
            }
        }
    }
    if (!Resources.fitsIn(rc, cluster, allocation.getAllocatedOrReservedResource(), availableResource)) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Node doesn't have enough available resource, asked=" + allocation.getAllocatedOrReservedResource() + " available=" + availableResource);
        }
        return false;
    }
    return true;
}
Also used : Resource(org.apache.hadoop.yarn.api.records.Resource) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Example 45 with RMContainer

use of org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer in project hadoop by apache.

the class FiCaSchedulerApp method internalUnreserve.

private boolean internalUnreserve(FiCaSchedulerNode node, SchedulerRequestKey schedulerKey) {
    Map<NodeId, RMContainer> reservedContainers = this.reservedContainers.get(schedulerKey);
    if (reservedContainers != null) {
        RMContainer reservedContainer = reservedContainers.remove(node.getNodeID());
        // as a consequence reservedcontainer might be null, adding NP-checks
        if (reservedContainer != null && reservedContainer.getContainer() != null && reservedContainer.getContainer().getResource() != null) {
            if (reservedContainers.isEmpty()) {
                this.reservedContainers.remove(schedulerKey);
            }
            // Reset the re-reservation count
            resetReReservations(schedulerKey);
            Resource resource = reservedContainer.getReservedResource();
            this.attemptResourceUsage.decReserved(node.getPartition(), resource);
            LOG.info("Application " + getApplicationId() + " unreserved " + " on node " + node + ", currently has " + reservedContainers.size() + " at priority " + schedulerKey.getPriority() + "; currentReservation " + this.attemptResourceUsage.getReserved() + " on node-label=" + node.getPartition());
            return true;
        }
    }
    return false;
}
Also used : NodeId(org.apache.hadoop.yarn.api.records.NodeId) Resource(org.apache.hadoop.yarn.api.records.Resource) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Aggregations

RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)166 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)55 Resource (org.apache.hadoop.yarn.api.records.Resource)49 Container (org.apache.hadoop.yarn.api.records.Container)48 Test (org.junit.Test)45 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)41 ArrayList (java.util.ArrayList)29 NodeId (org.apache.hadoop.yarn.api.records.NodeId)29 FiCaSchedulerApp (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp)29 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)28 FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)21 RMContainerImpl (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl)18 HashMap (java.util.HashMap)17 ResourceRequest (org.apache.hadoop.yarn.api.records.ResourceRequest)17 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)17 NodeUpdateSchedulerEvent (org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent)17 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)15 Priority (org.apache.hadoop.yarn.api.records.Priority)14 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)13 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)12