private void shedQueuedOpportunisticContainers() { int numAllowed = this.queuingLimit.getMaxQueueLength(); Iterator<Container> containerIter = queuedOpportunisticContainers.values().iterator(); while (containerIter.hasNext()) { Container container = containerIter.next(); // Do not shed PAUSED containers if (container.getContainerState() != ContainerState.PAUSED) { 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--; } } }
@SuppressWarnings("unchecked") private void reclaimOpportunisticContainerResources(Container container) { List<Container> extraOppContainersToReclaim = pickOpportunisticContainersToReclaimResources( container.getContainerId()); // Kill the opportunistic containers that were chosen. for (Container contToReclaim : extraOppContainersToReclaim) { String preemptionAction = usePauseEventForPreemption == true ? "paused" : "resumed"; LOG.info( "Container {} will be {} to start the " + "execution of guaranteed container {}.", contToReclaim.getContainerId(), preemptionAction, container.getContainerId()); if (usePauseEventForPreemption) { contToReclaim.sendPauseEvent( "Container Paused to make room for Guaranteed Container"); } else { contToReclaim.sendKillEvent( ContainerExitStatus.KILLED_BY_CONTAINER_SCHEDULER, "Container Killed to make room for Guaranteed Container."); } oppContainersToKill.put(contToReclaim.getContainerId(), contToReclaim); } }
"since max queue length [{}] has been reached", container.getContainerId(), maxOppQueueLength); container.sendKillEvent( ContainerExitStatus.KILLED_BY_CONTAINER_SCHEDULER, "Opportunistic container queue is full.");
@SuppressWarnings("unchecked") protected void stopContainerInternal(ContainerId containerID) throws YarnException, IOException { String containerIDStr = containerID.toString(); Container container = this.context.getContainers().get(containerID); LOG.info("Stopping container with container Id: " + containerIDStr); if (container == null) { if (!nodeStatusUpdater.isContainerRecentlyStopped(containerID)) { throw RPCUtil.getRemoteException("Container " + containerIDStr + " is not handled by this NodeManager"); } } else { if (container.isRecovering()) { throw new NMNotYetReadyException("Container " + containerIDStr + " is recovering, try later"); } context.getNMStateStore().storeContainerKilled(containerID); container.sendKillEvent(ContainerExitStatus.KILLED_BY_APPMASTER, "Container killed by the ApplicationMaster."); NMAuditLogger.logSuccess(container.getUser(), AuditConstants.STOP_CONTAINER, "ContainerManageImpl", containerID .getApplicationAttemptId().getApplicationId(), containerID); } }