/** * Contains the logic to do the actual polling. * * @return True if this poll operation did something, False otherwise */ private boolean doPoll() { boolean result = false; if (log.isDebugEnabled()) { log.debug("Checking status of containers previousely launched"); } for (Iterator<Container> iterator = launched.iterator(); iterator.hasNext();) { Container container = iterator.next(); ContainerStatus status = getCmTemplate(container).getContainerStatus(); ContainerState state = status.getState(); if (state.equals(ContainerState.COMPLETE)) { iterator.remove(); } else if (state.equals(ContainerState.RUNNING)) { iterator.remove(); if (getYarnEventPublisher() != null) { getYarnEventPublisher().publishContainerLaunched(this, container); } } } return result; }
if (state.equals(ContainerState.COMPLETE)) { if (exitStatus > 0 || exitStatus == -100 || exitStatus == -101 || exitStatus == -1000) { failed.add(cid);
private void killOrphanContainerOnNode(RMNode node, NMContainerStatus container) { if (!container.getContainerState().equals(ContainerState.COMPLETE)) { this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeCleanContainerEvent(node.getNodeID(), container.getContainerId())); } }
private void killOrphanContainerOnNode(RMNode node, NMContainerStatus container) { if (!container.getContainerState().equals(ContainerState.COMPLETE)) { this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeCleanContainerEvent(node.getNodeID(), container.getContainerId())); } }
private void killOrphanContainerOnNode(RMNode node, NMContainerStatus container) { if (!container.getContainerState().equals(ContainerState.COMPLETE)) { this.rmContext.getDispatcher().getEventHandler().handle( new RMNodeCleanContainerEvent(node.getNodeID(), container.getContainerId())); } }
@Override public RMContainerState transition(RMContainerImpl container, RMContainerEvent event) { NMContainerStatus report = ((RMContainerRecoverEvent) event).getContainerReport(); if (report.getContainerState().equals(ContainerState.COMPLETE)) { ContainerStatus status = ContainerStatus.newInstance(report.getContainerId(), report.getContainerState(), report.getDiagnostics(), report.getContainerExitStatus()); new FinishedTransition().transition(container, new RMContainerFinishedEvent(container.containerId, status, RMContainerEventType.FINISHED)); return RMContainerState.COMPLETED; } else if (report.getContainerState().equals(ContainerState.RUNNING)) { // Tell the app container.eventHandler.handle(new RMAppRunningOnNodeEvent(container .getApplicationAttemptId().getApplicationId(), container.nodeId)); return RMContainerState.RUNNING; } else { // This can never happen. LOG.warn("RMContainer received unexpected recover event with container" + " state " + report.getContainerState() + " while recovering."); return RMContainerState.RUNNING; } } }
@Override public RMContainerState transition(RMContainerImpl container, RMContainerEvent event) { NMContainerStatus report = ((RMContainerRecoverEvent) event).getContainerReport(); if (report.getContainerState().equals(ContainerState.COMPLETE)) { ContainerStatus status = ContainerStatus.newInstance(report.getContainerId(), report.getContainerState(), report.getDiagnostics(), report.getContainerExitStatus()); new FinishedTransition().transition(container, new RMContainerFinishedEvent(container.containerId, status, RMContainerEventType.FINISHED)); return RMContainerState.COMPLETED; } else if (report.getContainerState().equals(ContainerState.RUNNING)) { // Tell the app container.eventHandler.handle(new RMAppRunningOnNodeEvent(container .getApplicationAttemptId().getApplicationId(), container.nodeId)); return RMContainerState.RUNNING; } else { // This can never happen. LOG.warn("RMContainer received unexpected recover event with container" + " state " + report.getContainerState() + " while recovering."); return RMContainerState.RUNNING; } } }
private void waitForContainerToFinishOnNM(ContainerId containerId) { Context nmContet = yarnCluster.getNodeManager(0).getNMContext(); int interval = 4 * 60; // Max time for container token to expire. Assert.assertNotNull(nmContet.getContainers().containsKey(containerId)); while ((interval-- > 0) && !nmContet.getContainers().get(containerId) .cloneAndGetContainerStatus().getState() .equals(ContainerState.COMPLETE)) { try { LOG.info("Waiting for " + containerId + " to complete."); Thread.sleep(1000); } catch (InterruptedException e) { } } // Normally, Containers will be removed from NM context after they are // explicitly acked by RM. Now, manually remove it for testing. yarnCluster.getNodeManager(0).getNodeStatusUpdater() .addCompletedContainer(containerId); nmContet.getContainers().remove(containerId); }
private void waitForContainerToFinishOnNM(ContainerId containerId) throws InterruptedException { Context nmContext = yarnCluster.getNodeManager(0).getNMContext(); // Max time for container token to expire. final int timeout = 4 * 60 * 1000; // If the container is null, then it has already completed and been removed // from the Context by asynchronous calls. Container waitContainer = nmContext.getContainers().get(containerId); if (waitContainer != null) { try { LOG.info("Waiting for " + containerId + " to get to state " + ContainerState.COMPLETE); GenericTestUtils.waitFor(() -> ContainerState.COMPLETE.equals( waitContainer.cloneAndGetContainerStatus().getState()), 500, timeout); } catch (TimeoutException te) { LOG.error("TimeoutException", te); fail("Was waiting for " + containerId + " to get to state " + ContainerState.COMPLETE + " but was in state " + waitContainer.cloneAndGetContainerStatus().getState() + " after the timeout"); } } // Normally, Containers will be removed from NM context after they are // explicitly acked by RM. Now, manually remove it for testing. yarnCluster.getNodeManager(0).getNodeStatusUpdater() .addCompletedContainer(containerId); LOG.info("Removing container from NMContext, containerID = " + containerId); nmContext.getContainers().remove(containerId); }
container.getAllocationTags()); if (report.getContainerState().equals(ContainerState.COMPLETE)) { ContainerStatus status = ContainerStatus.newInstance(report.getContainerId(), RMContainerEventType.FINISHED)); return RMContainerState.COMPLETED; } else if (report.getContainerState().equals(ContainerState.RUNNING)) {
c.getContainerState().equals(ContainerState.RUNNING));
c.getContainerState().equals(ContainerState.RUNNING));