Search in sources :

Example 71 with Container

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.

the class NMTimelinePublisher method publishContainerLocalizationEvent.

private void publishContainerLocalizationEvent(ContainerLocalizationEvent event, String eventType) {
    Container container = event.getContainer();
    ContainerId containerId = container.getContainerId();
    TimelineEntity entity = createContainerEntity(containerId);
    TimelineEvent tEvent = new TimelineEvent();
    tEvent.setId(eventType);
    tEvent.setTimestamp(event.getTimestamp());
    entity.addEvent(tEvent);
    ApplicationId appId = container.getContainerId().getApplicationAttemptId().getApplicationId();
    try {
        // no need to put it as part of publisher as timeline client already has
        // Queuing concept
        TimelineV2Client timelineClient = getTimelineClient(appId);
        if (timelineClient != null) {
            timelineClient.putEntitiesAsync(entity);
        } else {
            LOG.error("Seems like client has been removed before the event could be" + " published for " + container.getContainerId());
        }
    } catch (IOException | YarnException e) {
        LOG.error("Failed to publish Container metrics for container " + container.getContainerId(), e);
    }
}
Also used : TimelineEvent(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent) Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) TimelineV2Client(org.apache.hadoop.yarn.client.api.TimelineV2Client) IOException(java.io.IOException) TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) YarnException(org.apache.hadoop.yarn.exceptions.YarnException)

Example 72 with Container

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.

the class ContainersMonitorImpl method changeContainerResource.

private void changeContainerResource(ContainerId containerId, Resource resource) {
    Container container = context.getContainers().get(containerId);
    // Check container existence
    if (container == null) {
        LOG.warn("Container " + containerId.toString() + "does not exist");
        return;
    }
    // YARN-5860: Route this through the ContainerScheduler to
    //       fix containerAllocation
    container.setResource(resource);
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)

Example 73 with Container

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.

the class ContainerScheduler method killOpportunisticContainers.

private void killOpportunisticContainers(Container container) {
    List<Container> extraOpportContainersToKill = pickOpportunisticContainersToKill(container.getContainerId());
    // Kill the opportunistic containers that were chosen.
    for (Container contToKill : extraOpportContainersToKill) {
        contToKill.sendKillEvent(ContainerExitStatus.KILLED_BY_CONTAINER_SCHEDULER, "Container Killed to make room for Guaranteed Container.");
        oppContainersToKill.put(contToKill.getContainerId(), contToKill);
        LOG.info("Opportunistic container {} will be killed in order to start the " + "execution of guaranteed container {}.", contToKill.getContainerId(), container.getContainerId());
    }
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)

Example 74 with Container

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container 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 75 with Container

use of org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container in project hadoop by apache.

the class ContainerScheduler method startContainersFromQueue.

private boolean startContainersFromQueue(Collection<Container> queuedContainers) {
    Iterator<Container> cIter = queuedContainers.iterator();
    boolean resourcesAvailable = true;
    while (cIter.hasNext() && resourcesAvailable) {
        Container container = cIter.next();
        if (this.utilizationTracker.hasResourcesAvailable(container)) {
            startAllocatedContainer(container);
            cIter.remove();
        } else {
            resourcesAvailable = false;
        }
    }
    return resourcesAvailable;
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)

Aggregations

Container (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)109 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)55 Test (org.junit.Test)43 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)33 Path (org.apache.hadoop.fs.Path)31 ArrayList (java.util.ArrayList)29 Application (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.Application)29 HashMap (java.util.HashMap)27 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)27 Configuration (org.apache.hadoop.conf.Configuration)24 IOException (java.io.IOException)20 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)18 ContainerEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerEvent)17 LocalDirsHandlerService (org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService)16 Collection (java.util.Collection)14 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)14 LocalResourceVisibility (org.apache.hadoop.yarn.api.records.LocalResourceVisibility)14 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)14 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)13 ApplicationEvent (org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEvent)13