Search in sources :

Example 91 with ContainerId

use of org.apache.hadoop.yarn.api.records.ContainerId in project hadoop by apache.

the class CapacityScheduler method completedContainerInternal.

@Override
protected void completedContainerInternal(RMContainer rmContainer, ContainerStatus containerStatus, RMContainerEventType event) {
    Container container = rmContainer.getContainer();
    ContainerId containerId = container.getId();
    // Get the application for the finished container
    FiCaSchedulerApp application = getCurrentAttemptForContainer(container.getId());
    ApplicationId appId = containerId.getApplicationAttemptId().getApplicationId();
    if (application == null) {
        LOG.info("Container " + container + " of" + " finished application " + appId + " completed with event " + event);
        return;
    }
    // Get the node on which the container was allocated
    FiCaSchedulerNode node = getNode(container.getNodeId());
    if (null == node) {
        LOG.info("Container " + container + " of" + " removed node " + container.getNodeId() + " completed with event " + event);
        return;
    }
    // Inform the queue
    LeafQueue queue = (LeafQueue) application.getQueue();
    queue.completedContainer(getClusterResource(), application, node, rmContainer, containerStatus, event, null, true);
}
Also used : RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) SchedulerContainer(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.SchedulerContainer) KillableContainer(org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.preemption.KillableContainer) FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) FiCaSchedulerApp(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 92 with ContainerId

use of org.apache.hadoop.yarn.api.records.ContainerId in project hadoop by apache.

the class CapacityScheduler method updateSchedulerHealth.

private void updateSchedulerHealth(long now, NodeId nodeId, CSAssignment assignment) {
    List<AssignmentInformation.AssignmentDetails> allocations = assignment.getAssignmentInformation().getAllocationDetails();
    List<AssignmentInformation.AssignmentDetails> reservations = assignment.getAssignmentInformation().getReservationDetails();
    if (!allocations.isEmpty()) {
        ContainerId allocatedContainerId = allocations.get(allocations.size() - 1).containerId;
        String allocatedQueue = allocations.get(allocations.size() - 1).queue;
        schedulerHealth.updateAllocation(now, nodeId, allocatedContainerId, allocatedQueue);
    }
    if (!reservations.isEmpty()) {
        ContainerId reservedContainerId = reservations.get(reservations.size() - 1).containerId;
        String reservedQueue = reservations.get(reservations.size() - 1).queue;
        schedulerHealth.updateReservation(now, nodeId, reservedContainerId, reservedQueue);
    }
    schedulerHealth.updateSchedulerReservationCounts(assignment.getAssignmentInformation().getNumReservations());
    schedulerHealth.updateSchedulerAllocationCounts(assignment.getAssignmentInformation().getNumAllocations());
    schedulerHealth.updateSchedulerRunDetails(now, assignment.getAssignmentInformation().getAllocated(), assignment.getAssignmentInformation().getReserved());
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId)

Example 93 with ContainerId

use of org.apache.hadoop.yarn.api.records.ContainerId in project hadoop by apache.

the class SchedulerApplicationAttempt method pullNewlyUpdatedContainers.

/**
   * A container is promoted if its executionType is changed from
   * OPPORTUNISTIC to GUARANTEED. It id demoted if the change is from
   * GUARANTEED to OPPORTUNISTIC.
   * @return Newly Promoted and Demoted containers
   */
private List<Container> pullNewlyUpdatedContainers(Map<ContainerId, RMContainer> newlyUpdatedContainers, ContainerUpdateType updateTpe) {
    List<Container> updatedContainers = new ArrayList<>();
    if (oppContainerContext == null && (ContainerUpdateType.DEMOTE_EXECUTION_TYPE == updateTpe || ContainerUpdateType.PROMOTE_EXECUTION_TYPE == updateTpe)) {
        return updatedContainers;
    }
    try {
        writeLock.lock();
        Iterator<Map.Entry<ContainerId, RMContainer>> i = newlyUpdatedContainers.entrySet().iterator();
        while (i.hasNext()) {
            Map.Entry<ContainerId, RMContainer> entry = i.next();
            ContainerId matchedContainerId = entry.getKey();
            RMContainer tempRMContainer = entry.getValue();
            RMContainer existingRMContainer = getRMContainer(matchedContainerId);
            if (existingRMContainer != null) {
                // swap containers
                existingRMContainer = getUpdateContext().swapContainer(tempRMContainer, existingRMContainer, updateTpe);
                getUpdateContext().removeFromOutstandingUpdate(tempRMContainer.getAllocatedSchedulerKey(), existingRMContainer.getContainer());
                Container updatedContainer = updateContainerAndNMToken(existingRMContainer, updateTpe);
                updatedContainers.add(updatedContainer);
            }
            tempContainerToKill.add(tempRMContainer);
            i.remove();
        }
        // Release all temporary containers
        Iterator<RMContainer> tempIter = tempContainerToKill.iterator();
        while (tempIter.hasNext()) {
            RMContainer c = tempIter.next();
            // Mark container for release (set RRs to null, so RM does not think
            // it is a recoverable container)
            ((RMContainerImpl) c).setResourceRequests(null);
            ((AbstractYarnScheduler) rmContext.getScheduler()).completedContainer(c, SchedulerUtils.createAbnormalContainerStatus(c.getContainerId(), SchedulerUtils.UPDATED_CONTAINER), RMContainerEventType.KILL);
            tempIter.remove();
        }
        return updatedContainers;
    } finally {
        writeLock.unlock();
    }
}
Also used : RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) Entry(java.util.Map.Entry) RMContainerImpl(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ArrayList(java.util.ArrayList) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Example 94 with ContainerId

use of org.apache.hadoop.yarn.api.records.ContainerId 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 95 with ContainerId

use of org.apache.hadoop.yarn.api.records.ContainerId 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)

Aggregations

ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)590 Test (org.junit.Test)339 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)173 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)169 ArrayList (java.util.ArrayList)161 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)119 Container (org.apache.hadoop.yarn.api.records.Container)104 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)94 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)79 MockRM (org.apache.hadoop.yarn.server.resourcemanager.MockRM)78 Path (org.apache.hadoop.fs.Path)77 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)77 HashMap (java.util.HashMap)75 Configuration (org.apache.hadoop.conf.Configuration)74 IOException (java.io.IOException)73 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)68 Resource (org.apache.hadoop.yarn.api.records.Resource)67 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)66 ResourceRequest (org.apache.hadoop.yarn.api.records.ResourceRequest)61 NodeId (org.apache.hadoop.yarn.api.records.NodeId)59