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();
}
}
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;
}
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--;
}
}
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());
}
}
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);
}
Aggregations