Search in sources :

Example 96 with Container

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

the class TestAMRMProxyService method testAllocateAndReleaseContainersForMultipleAM.

@Test
public void testAllocateAndReleaseContainersForMultipleAM() throws Exception {
    int numberOfApps = 5;
    for (int testAppId = 0; testAppId < numberOfApps; testAppId++) {
        RegisterApplicationMasterResponse registerResponse = registerApplicationMaster(testAppId);
        Assert.assertNotNull(registerResponse);
        List<Container> containers = getContainersAndAssert(testAppId, 10);
        releaseContainersAndAssert(testAppId, containers);
    }
    for (int testAppId = 0; testAppId < numberOfApps; testAppId++) {
        finishApplicationMaster(testAppId, FinalApplicationStatus.SUCCEEDED);
    }
}
Also used : Container(org.apache.hadoop.yarn.api.records.Container) RegisterApplicationMasterResponse(org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse) Test(org.junit.Test)

Example 97 with Container

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

the class RMNodeImpl method handleReportedIncreasedContainers.

private void handleReportedIncreasedContainers(List<Container> reportedIncreasedContainers) {
    for (Container container : reportedIncreasedContainers) {
        ContainerId containerId = container.getId();
        // more about this container
        if (containersToClean.contains(containerId)) {
            LOG.info("Container " + containerId + " already scheduled for " + "cleanup, no further processing");
            continue;
        }
        ApplicationId containerAppId = containerId.getApplicationAttemptId().getApplicationId();
        if (finishedApplications.contains(containerAppId)) {
            LOG.info("Container " + containerId + " belongs to an application that is already killed," + " no further processing");
            continue;
        }
        this.nmReportedIncreasedContainers.put(containerId, container);
    }
}
Also used : Container(org.apache.hadoop.yarn.api.records.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 98 with Container

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

the class AbstractYarnScheduler method recoverContainersOnNode.

public void recoverContainersOnNode(List<NMContainerStatus> containerReports, RMNode nm) {
    try {
        writeLock.lock();
        if (!rmContext.isWorkPreservingRecoveryEnabled() || containerReports == null || (containerReports != null && containerReports.isEmpty())) {
            return;
        }
        for (NMContainerStatus container : containerReports) {
            ApplicationId appId = container.getContainerId().getApplicationAttemptId().getApplicationId();
            RMApp rmApp = rmContext.getRMApps().get(appId);
            if (rmApp == null) {
                LOG.error("Skip recovering container " + container + " for unknown application.");
                killOrphanContainerOnNode(nm, container);
                continue;
            }
            SchedulerApplication<T> schedulerApp = applications.get(appId);
            if (schedulerApp == null) {
                LOG.info("Skip recovering container  " + container + " for unknown SchedulerApplication. " + "Application current state is " + rmApp.getState());
                killOrphanContainerOnNode(nm, container);
                continue;
            }
            LOG.info("Recovering container " + container);
            SchedulerApplicationAttempt schedulerAttempt = schedulerApp.getCurrentAppAttempt();
            if (!rmApp.getApplicationSubmissionContext().getKeepContainersAcrossApplicationAttempts()) {
                // Do not recover containers for stopped attempt or previous attempt.
                if (schedulerAttempt.isStopped() || !schedulerAttempt.getApplicationAttemptId().equals(container.getContainerId().getApplicationAttemptId())) {
                    LOG.info("Skip recovering container " + container + " for already stopped attempt.");
                    killOrphanContainerOnNode(nm, container);
                    continue;
                }
            }
            // create container
            RMContainer rmContainer = recoverAndCreateContainer(container, nm);
            // recover RMContainer
            rmContainer.handle(new RMContainerRecoverEvent(container.getContainerId(), container));
            // recover scheduler node
            SchedulerNode schedulerNode = nodeTracker.getNode(nm.getNodeID());
            schedulerNode.recoverContainer(rmContainer);
            // recover queue: update headroom etc.
            Queue queue = schedulerAttempt.getQueue();
            queue.recoverContainer(getClusterResource(), schedulerAttempt, rmContainer);
            // recover scheduler attempt
            schedulerAttempt.recoverContainer(schedulerNode, rmContainer);
            // set master container for the current running AMContainer for this
            // attempt.
            RMAppAttempt appAttempt = rmApp.getCurrentAppAttempt();
            if (appAttempt != null) {
                Container masterContainer = appAttempt.getMasterContainer();
                // container ID stored in AppAttempt.
                if (masterContainer != null && masterContainer.getId().equals(rmContainer.getContainerId())) {
                    ((RMContainerImpl) rmContainer).setAMContainer(true);
                }
            }
            if (schedulerAttempt.getPendingRelease().remove(container.getContainerId())) {
                // release the container
                rmContainer.handle(new RMContainerFinishedEvent(container.getContainerId(), SchedulerUtils.createAbnormalContainerStatus(container.getContainerId(), SchedulerUtils.RELEASED_CONTAINER), RMContainerEventType.RELEASED));
                LOG.info(container.getContainerId() + " is released by application.");
            }
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMAppAttempt(org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) RMContainerRecoverEvent(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerRecoverEvent) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) RMContainerImpl(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerImpl) NMContainerStatus(org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus) RMContainerFinishedEvent(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerFinishedEvent) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId)

Example 99 with Container

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

the class AbstractYarnScheduler method getTransferredContainers.

/*
   * YARN-3136 removed synchronized lock for this method for performance
   * purposes
   */
public List<Container> getTransferredContainers(ApplicationAttemptId currentAttempt) {
    ApplicationId appId = currentAttempt.getApplicationId();
    SchedulerApplication<T> app = applications.get(appId);
    List<Container> containerList = new ArrayList<Container>();
    RMApp appImpl = this.rmContext.getRMApps().get(appId);
    if (appImpl.getApplicationSubmissionContext().getUnmanagedAM()) {
        return containerList;
    }
    if (app == null) {
        return containerList;
    }
    Collection<RMContainer> liveContainers = app.getCurrentAppAttempt().getLiveContainers();
    ContainerId amContainerId = rmContext.getRMApps().get(appId).getCurrentAppAttempt().getMasterContainer().getId();
    for (RMContainer rmContainer : liveContainers) {
        if (!rmContainer.getContainerId().equals(amContainerId)) {
            containerList.add(rmContainer.getContainer());
        }
    }
    return containerList;
}
Also used : RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ArrayList(java.util.ArrayList) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)

Example 100 with Container

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

the class AbstractYarnScheduler method createDemotedRMContainer.

private RMContainer createDemotedRMContainer(SchedulerApplicationAttempt appAttempt, OpportunisticContainerContext oppCntxt, RMContainer rmContainer) {
    SchedulerRequestKey sk = SchedulerRequestKey.extractFrom(rmContainer.getContainer());
    Container demotedContainer = BuilderUtils.newContainer(ContainerId.newContainerId(appAttempt.getApplicationAttemptId(), oppCntxt.getContainerIdGenerator().generateContainerId()), rmContainer.getContainer().getNodeId(), rmContainer.getContainer().getNodeHttpAddress(), rmContainer.getContainer().getResource(), sk.getPriority(), null, ExecutionType.OPPORTUNISTIC, sk.getAllocationRequestId());
    demotedContainer.setVersion(rmContainer.getContainer().getVersion());
    return SchedulerUtils.createOpportunisticRmContainer(rmContext, demotedContainer, false);
}
Also used : RMContainer(org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer) Container(org.apache.hadoop.yarn.api.records.Container) SchedulerRequestKey(org.apache.hadoop.yarn.server.scheduler.SchedulerRequestKey)

Aggregations

Container (org.apache.hadoop.yarn.api.records.Container)336 Test (org.junit.Test)187 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)161 RMContainer (org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer)107 Resource (org.apache.hadoop.yarn.api.records.Resource)84 NodeId (org.apache.hadoop.yarn.api.records.NodeId)83 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)77 Configuration (org.apache.hadoop.conf.Configuration)73 ArrayList (java.util.ArrayList)68 Priority (org.apache.hadoop.yarn.api.records.Priority)56 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)55 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)55 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)48 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)47 AllocateResponse (org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse)44 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)42 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)40 ResourceRequest (org.apache.hadoop.yarn.api.records.ResourceRequest)39 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)34 AMContainerMap (org.apache.tez.dag.app.rm.container.AMContainerMap)33