@Override public RMContainer getRMContainer(ContainerId containerId) { SchedulerApplicationAttempt attempt = getCurrentAttemptForContainer(containerId); return (attempt == null) ? null : attempt.getRMContainer(containerId); }
@Override public RMContainer getRMContainer(ContainerId containerId) { SchedulerApplicationAttempt attempt = getCurrentAttemptForContainer(containerId); return (attempt == null) ? null : attempt.getRMContainer(containerId); }
@Override public RMContainer getRMContainer(ContainerId containerId) { SchedulerApplicationAttempt attempt = getCurrentAttemptForContainer(containerId); return (attempt == null) ? null : attempt.getRMContainer(containerId); }
/** * Recover resource request back from RMContainer when a container is * preempted before AM pulled the same. If container is pulled by * AM, then RMContainer will not have resource request to recover. * @param rmContainer */ protected void recoverResourceRequestForContainer(RMContainer rmContainer) { List<ResourceRequest> requests = rmContainer.getResourceRequests(); // If container state is moved to ACQUIRED, request will be empty. if (requests == null) { return; } // Add resource request back to Scheduler. SchedulerApplicationAttempt schedulerAttempt = getCurrentAttemptForContainer(rmContainer.getContainerId()); if (schedulerAttempt != null) { schedulerAttempt.recoverResourceRequests(requests); } }
/** * Recover resource request back from RMContainer when a container is * preempted before AM pulled the same. If container is pulled by * AM, then RMContainer will not have resource request to recover. * @param rmContainer */ protected void recoverResourceRequestForContainer(RMContainer rmContainer) { List<ResourceRequest> requests = rmContainer.getResourceRequests(); // If container state is moved to ACQUIRED, request will be empty. if (requests == null) { return; } // Add resource request back to Scheduler. SchedulerApplicationAttempt schedulerAttempt = getCurrentAttemptForContainer(rmContainer.getContainerId()); if (schedulerAttempt != null) { schedulerAttempt.recoverResourceRequests(requests); } }
/** * Recover resource request back from RMContainer when a container is * preempted before AM pulled the same. If container is pulled by * AM, then RMContainer will not have resource request to recover. * @param rmContainer rmContainer */ private void recoverResourceRequestForContainer(RMContainer rmContainer) { ContainerRequest containerRequest = rmContainer.getContainerRequest(); // If container state is moved to ACQUIRED, request will be empty. if (containerRequest == null) { return; } // Add resource request back to Scheduler ApplicationAttempt. // We lookup the application-attempt here again using // getCurrentApplicationAttempt() because there is only one app-attempt at // any point in the scheduler. But in corner cases, AMs can crash, // corresponding containers get killed and recovered to the same-attempt, // but because the app-attempt is extinguished right after, the recovered // requests don't serve any purpose, but that's okay. SchedulerApplicationAttempt schedulerAttempt = getCurrentAttemptForContainer(rmContainer.getContainerId()); if (schedulerAttempt != null) { schedulerAttempt.recoverResourceRequestsForContainer(containerRequest); } }
/** * 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))); } }
protected void containerLaunchedOnNode( ContainerId containerId, SchedulerNode node) { try { readLock.lock(); // Get the application for the finished container SchedulerApplicationAttempt application = getCurrentAttemptForContainer(containerId); if (application == null) { LOG.info("Unknown application " + containerId.getApplicationAttemptId() .getApplicationId() + " launched container " + containerId + " on node: " + node); this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeCleanContainerEvent(node.getNodeID(), containerId)); return; } application.containerLaunchedOnNode(containerId, node.getNodeID()); node.containerStarted(containerId); } finally { readLock.unlock(); } }
protected synchronized void containerLaunchedOnNode( ContainerId containerId, SchedulerNode node) { // Get the application for the finished container SchedulerApplicationAttempt application = getCurrentAttemptForContainer (containerId); if (application == null) { LOG.info("Unknown application " + containerId.getApplicationAttemptId().getApplicationId() + " launched container " + containerId + " on node: " + node); this.rmContext.getDispatcher().getEventHandler() .handle(new RMNodeCleanContainerEvent(node.getNodeID(), containerId)); return; } application.containerLaunchedOnNode(containerId, node.getNodeID()); }
protected synchronized void containerLaunchedOnNode( ContainerId containerId, SchedulerNode node) { // Get the application for the finished container SchedulerApplicationAttempt application = getCurrentAttemptForContainer (containerId); if (application == null) { LOG.info("Unknown application " + containerId.getApplicationAttemptId().getApplicationId() + " launched container " + containerId + " on node: " + node); this.rmContext.getDispatcher().getEventHandler() .handle(new RMNodeCleanContainerEvent(node.getNodeID(), containerId)); return; } application.containerLaunchedOnNode(containerId, node.getNodeID()); }
new RMContainerFinishedEvent(containerId, containerStatus, event)); SchedulerApplicationAttempt schedulerAttempt = getCurrentAttemptForContainer(containerId); if (schedulerAttempt != null) { schedulerAttempt.removeRMContainer(containerId);
public static RMContainer createOpportunisticRmContainer(RMContext rmContext, Container container, boolean isRemotelyAllocated) { SchedulerApplicationAttempt appAttempt = ((AbstractYarnScheduler) rmContext.getScheduler()) .getCurrentAttemptForContainer(container.getId()); RMContainer rmContainer = new RMContainerImpl(container, SchedulerRequestKey.extractFrom(container), appAttempt.getApplicationAttemptId(), container.getNodeId(), appAttempt.getUser(), rmContext, isRemotelyAllocated); appAttempt.addRMContainer(container.getId(), rmContainer); ((AbstractYarnScheduler) rmContext.getScheduler()).getNode( container.getNodeId()).allocateContainer(rmContainer); return rmContainer; } }
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())); }
SchedulerApplicationAttempt schedulerAttempt = ((AbstractYarnScheduler) rm1.getResourceScheduler()) .getCurrentAttemptForContainer(containerId6); while (schedulerAttempt.getReservedContainers().isEmpty()) { System.out.println("Waiting for container " + containerId6 .getCurrentAttemptForContainer(containerId2);
SchedulerApplicationAttempt schedulerAttempt = ((AbstractYarnScheduler) rm1.getResourceScheduler()) .getCurrentAttemptForContainer(containerId6); while (schedulerAttempt.getReservedContainers().isEmpty()) { System.out.println("Waiting for container " + containerId6 .getCurrentAttemptForContainer(containerId2);