Search in sources :

Example 76 with Container

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

the class ContainerScheduler method onContainerCompleted.

private void onContainerCompleted(Container container) {
    oppContainersToKill.remove(container.getContainerId());
    // This could be killed externally for eg. by the ContainerManager,
    // in which case, the container might still be queued.
    Container queued = queuedOpportunisticContainers.remove(container.getContainerId());
    if (queued == null) {
        queuedGuaranteedContainers.remove(container.getContainerId());
    }
    // decrement only if it was a running container
    Container completedContainer = runningContainers.remove(container.getContainerId());
    if (completedContainer != null) {
        this.utilizationTracker.subtractContainerResource(container);
        if (container.getContainerTokenIdentifier().getExecutionType() == ExecutionType.OPPORTUNISTIC) {
            this.metrics.completeOpportunisticContainer(container.getResource());
        }
        startPendingContainers();
    }
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)

Example 77 with Container

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

Example 78 with Container

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

the class ContainerScheduler method shedQueuedOpportunisticContainers.

private void shedQueuedOpportunisticContainers() {
    int numAllowed = this.queuingLimit.getMaxQueueLength();
    Iterator<Container> containerIter = queuedOpportunisticContainers.values().iterator();
    while (containerIter.hasNext()) {
        Container container = containerIter.next();
        if (numAllowed <= 0) {
            container.sendKillEvent(ContainerExitStatus.KILLED_BY_CONTAINER_SCHEDULER, "Container De-queued to meet NM queuing limits.");
            containerIter.remove();
            LOG.info("Opportunistic container {} will be killed to meet NM queuing" + " limits.", container.getContainerId());
        }
        numAllowed--;
    }
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container)

Example 79 with Container

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

the class DefaultLinuxContainerRuntime method signalContainer.

@Override
public void signalContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException {
    Container container = ctx.getContainer();
    PrivilegedOperation signalOp = new PrivilegedOperation(PrivilegedOperation.OperationType.SIGNAL_CONTAINER);
    signalOp.appendArgs(ctx.getExecutionAttribute(RUN_AS_USER), ctx.getExecutionAttribute(USER), Integer.toString(PrivilegedOperation.RunAsUserCommand.SIGNAL_CONTAINER.getValue()), ctx.getExecutionAttribute(PID), Integer.toString(ctx.getExecutionAttribute(SIGNAL).getValue()));
    //Some failures here are acceptable. Let the calling executor decide.
    signalOp.disableFailureLogging();
    try {
        PrivilegedOperationExecutor executor = PrivilegedOperationExecutor.getInstance(conf);
        executor.executePrivilegedOperation(null, signalOp, null, container.getLaunchContext().getEnvironment(), false, true);
    } catch (PrivilegedOperationException e) {
        // acceptable. Let the calling executor decide what to do.
        throw new ContainerExecutionException("Signal container failed", e.getExitCode(), e.getOutput(), e.getErrorOutput());
    }
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) PrivilegedOperationExecutor(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationExecutor) ContainerExecutionException(org.apache.hadoop.yarn.server.nodemanager.containermanager.runtime.ContainerExecutionException) PrivilegedOperationException(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperationException) PrivilegedOperation(org.apache.hadoop.yarn.server.nodemanager.containermanager.linux.privileged.PrivilegedOperation)

Example 80 with Container

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

the class DelegatingLinuxContainerRuntime method reapContainer.

@Override
public void reapContainer(ContainerRuntimeContext ctx) throws ContainerExecutionException {
    Container container = ctx.getContainer();
    LinuxContainerRuntime runtime = pickContainerRuntime(container);
    runtime.reapContainer(ctx);
}
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