protected void releaseContainers(List<ContainerId> containers, SchedulerApplicationAttempt attempt) { for (ContainerId containerId : containers) { RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { if (System.currentTimeMillis() - ResourceManager.getClusterTimeStamp() < nmExpireInterval) { LOG.info(containerId + " doesn't exist. Add the container" + " to the release request cache as it maybe on recovery."); attempt.getPendingRelease().add(containerId); } else { RMAuditLogger.logFailure(attempt.getUser(), AuditConstants.RELEASE_CONTAINER, "Unauthorized access or invalid container", "Scheduler", "Trying to release container not owned by app or with invalid id.", attempt.getApplicationId(), containerId, null); } } completedContainer(rmContainer, SchedulerUtils.createAbnormalContainerStatus(containerId, SchedulerUtils.RELEASED_CONTAINER), RMContainerEventType.RELEASED); } }
protected void releaseContainers(List<ContainerId> containers, SchedulerApplicationAttempt attempt) { for (ContainerId containerId : containers) { RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { if (System.currentTimeMillis() - ResourceManager.getClusterTimeStamp() < nmExpireInterval) { LOG.info(containerId + " doesn't exist. Add the container" + " to the release request cache as it maybe on recovery."); synchronized (attempt) { attempt.getPendingRelease().add(containerId); } } else { RMAuditLogger.logFailure(attempt.getUser(), AuditConstants.RELEASE_CONTAINER, "Unauthorized access or invalid container", "Scheduler", "Trying to release container not owned by app or with invalid id.", attempt.getApplicationId(), containerId); } } completedContainer(rmContainer, SchedulerUtils.createAbnormalContainerStatus(containerId, SchedulerUtils.RELEASED_CONTAINER), RMContainerEventType.RELEASED); } }
protected void releaseContainers(List<ContainerId> containers, SchedulerApplicationAttempt attempt) { for (ContainerId containerId : containers) { RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { if (System.currentTimeMillis() - ResourceManager.getClusterTimeStamp() < nmExpireInterval) { LOG.info(containerId + " doesn't exist. Add the container" + " to the release request cache as it maybe on recovery."); synchronized (attempt) { attempt.getPendingRelease().add(containerId); } } else { RMAuditLogger.logFailure(attempt.getUser(), AuditConstants.RELEASE_CONTAINER, "Unauthorized access or invalid container", "Scheduler", "Trying to release container not owned by app or with invalid id.", attempt.getApplicationId(), containerId); } } completedContainer(rmContainer, SchedulerUtils.createAbnormalContainerStatus(containerId, SchedulerUtils.RELEASED_CONTAINER), RMContainerEventType.RELEASED); } }
public Boolean get() { // release cache is cleaned up and previous running container is not // recovered return scheduler.getApplicationAttempt(am1.getApplicationAttemptId()) .getPendingRelease().isEmpty() && scheduler.getRMContainer(runningContainer) == null; } }, 1000, 20000);
public Boolean get() { // release cache is cleaned up and previous running container is not // recovered return scheduler.getApplicationAttempt(am1.getApplicationAttemptId()) .getPendingRelease().isEmpty() && scheduler.getRMContainer(runningContainer) == null; } }, 1000, 20000);
/** * Rollback container update after expiry. * @param containerId ContainerId. */ protected void rollbackContainerUpdate( ContainerId containerId) { RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { LOG.info("Cannot rollback resource for container " + containerId + ". The container does not exist."); return; } T app = getCurrentAttemptForContainer(containerId); if (getCurrentAttemptForContainer(containerId) == null) { LOG.info("Cannot rollback resource for container " + containerId + ". The application that the container " + "belongs to does not exist."); return; } if (Resources.fitsIn(rmContainer.getLastConfirmedResource(), rmContainer.getContainer().getResource())) { LOG.info("Roll back resource for container " + containerId); handleDecreaseRequests(app, Arrays.asList( UpdateContainerRequest.newInstance( rmContainer.getContainer().getVersion(), rmContainer.getContainerId(), ContainerUpdateType.DECREASE_RESOURCE, rmContainer.getLastConfirmedResource(), null))); } }
ContainerId containerId = completedContainer.getContainerId(); LOG.debug("Container FINISHED: " + containerId); RMContainer container = getRMContainer(containerId); completedContainer(container, completedContainer, RMContainerEventType.FINISHED);
/** * Sanity check increase/decrease request, and return * SchedulerContainerResourceChangeRequest according to given * UpdateContainerRequest. * * <pre> * - Returns non-null value means validation succeeded * - Throw exception when any other error happens * </pre> */ private SchedContainerChangeRequest createSchedContainerChangeRequest( UpdateContainerRequest request, boolean increase) throws YarnException { ContainerId containerId = request.getContainerId(); RMContainer rmContainer = getRMContainer(containerId); if (null == rmContainer) { String msg = "Failed to get rmContainer for " + (increase ? "increase" : "decrease") + " request, with container-id=" + containerId; throw new InvalidResourceRequestException(msg); } SchedulerNode schedulerNode = getSchedulerNode(rmContainer.getAllocatedNode()); return new SchedContainerChangeRequest( this.rmContext, schedulerNode, rmContainer, request.getCapability()); }
protected void containerIncreasedOnNode(ContainerId containerId, SchedulerNode node, Container increasedContainerReportedByNM) { /* * No lock is required, as this method is protected by scheduler's writeLock */ // Get the application for the finished container SchedulerApplicationAttempt application = getCurrentAttemptForContainer( containerId); if (application == null) { LOG.info("Unknown application " + containerId.getApplicationAttemptId() .getApplicationId() + " increased container " + containerId + " on node: " + node); this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeCleanContainerEvent(node.getNodeID(), containerId)); return; } RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { // Some unknown container sneaked into the system. Kill it. this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeCleanContainerEvent(node.getNodeID(), containerId)); return; } rmContainer.handle(new RMContainerNMDoneChangeResourceEvent(containerId, increasedContainerReportedByNM.getResource())); }
assertNull(scheduler.getRMContainer(runningContainer.getContainerId())); assertNull(scheduler.getRMContainer(completedContainer.getContainerId())); assertNull(scheduler.getRMContainer(previousAttemptContainer.getContainerId()));
assertNull(scheduler.getRMContainer(runningContainer.getContainerId())); assertNull(scheduler.getRMContainer(completedContainer.getContainerId()));
((AbstractYarnScheduler) rm1.getResourceScheduler()); Assert.assertTrue(scheduler.getRMContainer( attempt0.getMasterContainer().getId()).isAMContainer()); Assert.assertTrue(scheduler.getRMContainer( attempt0.getMasterContainer().getId()).isAMContainer());
@Test(timeout = 100000) public void testMaxAttemptOneMeansOne() throws Exception { getConf().setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, 1); getConf().setBoolean(YarnConfiguration.RECOVERY_ENABLED, true); getConf().set( YarnConfiguration.RM_STORE, MemoryRMStateStore.class.getName()); MockRM rm1 = new MockRM(getConf()); rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 8000, rm1.getResourceTrackerService()); nm1.registerNode(); RMApp app1 = rm1.submitApp(200); RMAppAttempt attempt1 = app1.getCurrentAppAttempt(); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); AbstractYarnScheduler scheduler = (AbstractYarnScheduler) rm1.getResourceScheduler(); ContainerId amContainer = ContainerId.newContainerId(am1.getApplicationAttemptId(), 1); // Preempt the attempt; scheduler.killContainer(scheduler.getRMContainer(amContainer)); rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); TestSchedulerUtils.waitSchedulerApplicationAttemptStopped(scheduler, am1.getApplicationAttemptId()); // AM should not be restarted. rm1.waitForState(app1.getApplicationId(), RMAppState.FAILED); Assert.assertEquals(1, app1.getAppAttempts().size()); rm1.stop(); }
schedulerApp.getCurrentAppAttempt(); assertTrue(schedulerAttempt.getLiveContainers() .contains(scheduler.getRMContainer(amContainer.getContainerId()))); assertTrue(schedulerAttempt.getLiveContainers() .contains(scheduler.getRMContainer(runningContainer.getContainerId()))); assertEquals(schedulerAttempt.getCurrentConsumption(), usedResources);
schedulerApp.getCurrentAppAttempt(); assertTrue(schedulerAttempt.getLiveContainers() .contains(scheduler.getRMContainer(amContainer.getContainerId()))); assertTrue(schedulerAttempt.getLiveContainers() .contains(scheduler.getRMContainer(runningContainer.getContainerId()))); assertEquals(schedulerAttempt.getCurrentConsumption(), usedResources);
schedulerApp.getCurrentAppAttempt(); assertTrue(schedulerAttempt.getLiveContainers().contains( scheduler.getRMContainer(amContainer.getContainerId()))); assertTrue(schedulerAttempt.getLiveContainers().contains( scheduler.getRMContainer(runningContainer.getContainerId()))); assertEquals(schedulerAttempt.getCurrentConsumption(), usedResources);
schedulerApp.getCurrentAppAttempt(); assertTrue(schedulerAttempt.getLiveContainers().contains( scheduler.getRMContainer(amContainer.getContainerId()))); assertTrue(schedulerAttempt.getLiveContainers().contains( scheduler.getRMContainer(runningContainer.getContainerId()))); assertEquals(schedulerAttempt.getCurrentConsumption(), usedResources);
ContainerId.newContainerId(am1.getApplicationAttemptId(), 1); scheduler.killContainer(scheduler.getRMContainer(amContainer)); scheduler.killContainer(scheduler.getRMContainer(amContainer2));
scheduler.killContainer(scheduler.getRMContainer(amContainer));