@Override public void transition(RMNodeImpl rmNode, RMNodeEvent event) { rmNode.containersToClean.add((( RMNodeCleanContainerEvent) event).getContainerId()); } }
@Override public void transition(RMContainerImpl container, RMContainerEvent event) { // Unregister from containerAllocationExpirer. container.containerAllocationExpirer.unregister(container .getContainerId()); // Inform node container.eventHandler.handle(new RMNodeCleanContainerEvent( container.nodeId, container.containerId)); // Inform appAttempt super.transition(container, event); } }
@Override public void transition(RMContainerImpl container, RMContainerEvent event) { // Unregister from containerAllocationExpirer. container.containerAllocationExpirer.unregister(container .getContainerId()); // Inform node container.eventHandler.handle(new RMNodeCleanContainerEvent( container.nodeId, container.containerId)); // Inform appAttempt super.transition(container, event); } }
@SuppressWarnings("unchecked") public void containerLaunchedOnNode(ContainerId containerId, NodeId nodeId) { try { writeLock.lock(); // Inform the container RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { // Some unknown container sneaked into the system. Kill it. rmContext.getDispatcher().getEventHandler().handle( new RMNodeCleanContainerEvent(nodeId, containerId)); return; } rmContainer.handle( new RMContainerEvent(containerId, RMContainerEventType.LAUNCHED)); } finally { writeLock.unlock(); } }
@Override public void transition(RMNodeImpl rmNode, RMNodeEvent event) { rmNode.containersToClean.add((( RMNodeCleanContainerEvent) event).getContainerId()); } }
@Override public void transition(RMContainerImpl container, RMContainerEvent event) { // Unregister from containerAllocationExpirer. container.containerAllocationExpirer.unregister( new AllocationExpirationInfo(container.getContainerId())); // Inform node container.eventHandler.handle(new RMNodeCleanContainerEvent( container.nodeId, container.getContainerId())); // Inform appAttempt super.transition(container, event); } }
@Override public void transition(RMNodeImpl rmNode, RMNodeEvent event) { rmNode.containersToClean.add((( RMNodeCleanContainerEvent) event).getContainerId()); } }
@SuppressWarnings("unchecked") public synchronized void containerLaunchedOnNode(ContainerId containerId, NodeId nodeId) { // Inform the container RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { // Some unknown container sneaked into the system. Kill it. rmContext.getDispatcher().getEventHandler() .handle(new RMNodeCleanContainerEvent(nodeId, containerId)); return; } rmContainer.handle(new RMContainerEvent(containerId, RMContainerEventType.LAUNCHED)); }
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(); } }
@SuppressWarnings("unchecked") public synchronized void containerLaunchedOnNode(ContainerId containerId, NodeId nodeId) { // Inform the container RMContainer rmContainer = getRMContainer(containerId); if (rmContainer == null) { // Some unknown container sneaked into the system. Kill it. rmContext.getDispatcher().getEventHandler() .handle(new RMNodeCleanContainerEvent(nodeId, containerId)); return; } rmContainer.handle(new RMContainerEvent(containerId, RMContainerEventType.LAUNCHED)); }
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()); }
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())); } }
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 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())); }
@Test (timeout = 5000) public void testExpiredContainer() { // Start the node node.handle(new RMNodeStartedEvent(null, null, null)); verify(scheduler).handle(any(NodeAddedSchedulerEvent.class)); // Expire a container ContainerId completedContainerId = BuilderUtils.newContainerId( BuilderUtils.newApplicationAttemptId( BuilderUtils.newApplicationId(0, 0), 0), 0); node.handle(new RMNodeCleanContainerEvent(null, completedContainerId)); Assert.assertEquals(1, node.getContainersToCleanUp().size()); // Now verify that scheduler isn't notified of an expired container // by checking number of 'completedContainers' it got in the previous event RMNodeStatusEvent statusEvent = getMockRMNodeStatusEvent(null); ContainerStatus containerStatus = mock(ContainerStatus.class); doReturn(completedContainerId).when(containerStatus).getContainerId(); doReturn(Collections.singletonList(containerStatus)). when(statusEvent).getContainers(); node.handle(statusEvent); /* Expect the scheduler call handle function 2 times * 1. RMNode status from new to Running, handle the add_node event * 2. handle the node update event */ verify(scheduler,times(2)).handle(any(NodeUpdateSchedulerEvent.class)); }
@Test (timeout = 5000) public void testExpiredContainer() { // Start the node node.handle(new RMNodeStartedEvent(null, null, null)); verify(scheduler).handle(any(NodeAddedSchedulerEvent.class)); // Expire a container ContainerId completedContainerId = BuilderUtils.newContainerId( BuilderUtils.newApplicationAttemptId( BuilderUtils.newApplicationId(0, 0), 0), 0); node.handle(new RMNodeCleanContainerEvent(null, completedContainerId)); Assert.assertEquals(1, node.getContainersToCleanUp().size()); // Now verify that scheduler isn't notified of an expired container // by checking number of 'completedContainers' it got in the previous event RMNodeStatusEvent statusEvent = getMockRMNodeStatusEvent(); ContainerStatus containerStatus = mock(ContainerStatus.class); doReturn(completedContainerId).when(containerStatus).getContainerId(); doReturn(Collections.singletonList(containerStatus)). when(statusEvent).getContainers(); node.handle(statusEvent); /* Expect the scheduler call handle function 2 times * 1. RMNode status from new to Running, handle the add_node event * 2. handle the node update event */ verify(scheduler,times(2)).handle(any(NodeUpdateSchedulerEvent.class)); }
+ " rm-size-resource:" + rmContainerResource + " nm-size-resource:" + nmContainerResource); container.eventHandler.handle(new RMNodeCleanContainerEvent( container.nodeId, container.getContainerId()));
@Test(timeout=20000) public void testUpdateHeartbeatResponseForCleanup() { RMNodeImpl node = getRunningNode(); NodeId nodeId = node.getNodeID(); // Expire a container ContainerId completedContainerId = BuilderUtils.newContainerId( BuilderUtils.newApplicationAttemptId( BuilderUtils.newApplicationId(0, 0), 0), 0); node.handle(new RMNodeCleanContainerEvent(nodeId, completedContainerId)); Assert.assertEquals(1, node.getContainersToCleanUp().size()); // Finish an application ApplicationId finishedAppId = BuilderUtils.newApplicationId(0, 1); node.handle(new RMNodeCleanAppEvent(nodeId, finishedAppId)); Assert.assertEquals(1, node.getAppsToCleanup().size()); // Verify status update does not clear containers/apps to cleanup // but updating heartbeat response for cleanup does RMNodeStatusEvent statusEvent = getMockRMNodeStatusEvent(null); node.handle(statusEvent); Assert.assertEquals(1, node.getContainersToCleanUp().size()); Assert.assertEquals(1, node.getAppsToCleanup().size()); NodeHeartbeatResponse hbrsp = Records.newRecord(NodeHeartbeatResponse.class); node.setAndUpdateNodeHeartbeatResponse(hbrsp); Assert.assertEquals(0, node.getContainersToCleanUp().size()); Assert.assertEquals(0, node.getAppsToCleanup().size()); Assert.assertEquals(1, hbrsp.getContainersToCleanup().size()); Assert.assertEquals(completedContainerId, hbrsp.getContainersToCleanup().get(0)); Assert.assertEquals(1, hbrsp.getApplicationsToCleanup().size()); Assert.assertEquals(finishedAppId, hbrsp.getApplicationsToCleanup().get(0)); }