private static void handleRunningAppOnNode(RMNodeImpl rmNode, RMContext context, ApplicationId appId, NodeId nodeId) { RMApp app = context.getRMApps().get(appId); // if we failed getting app by appId, maybe something wrong happened, just // add the app to the finishedApplications list so that the app can be // cleaned up on the NM if (null == app) { LOG.warn("Cannot get RMApp by appId=" + appId + ", just added it to finishedApplications list for cleanup"); rmNode.finishedApplications.add(appId); return; } context.getDispatcher().getEventHandler() .handle(new RMAppRunningOnNodeEvent(appId, nodeId)); }
private static void handleRunningAppOnNode(RMNodeImpl rmNode, RMContext context, ApplicationId appId, NodeId nodeId) { RMApp app = context.getRMApps().get(appId); // if we failed getting app by appId, maybe something wrong happened, just // add the app to the finishedApplications list so that the app can be // cleaned up on the NM if (null == app) { LOG.warn("Cannot get RMApp by appId=" + appId + ", just added it to finishedApplications list for cleanup"); rmNode.finishedApplications.add(appId); rmNode.runningApplications.remove(appId); return; } // Add running applications back due to Node add or Node reconnection. rmNode.runningApplications.add(appId); context.getDispatcher().getEventHandler() .handle(new RMAppRunningOnNodeEvent(appId, nodeId)); }
private static void handleRunningAppOnNode(RMNodeImpl rmNode, RMContext context, ApplicationId appId, NodeId nodeId) { RMApp app = context.getRMApps().get(appId); // if we failed getting app by appId, maybe something wrong happened, just // add the app to the finishedApplications list so that the app can be // cleaned up on the NM if (null == app) { LOG.warn("Cannot get RMApp by appId=" + appId + ", just added it to finishedApplications list for cleanup"); rmNode.finishedApplications.add(appId); return; } context.getDispatcher().getEventHandler() .handle(new RMAppRunningOnNodeEvent(appId, nodeId)); }
@Override public void transition(RMContainerImpl container, RMContainerEvent event) { // Clear ResourceRequest stored in RMContainer container.setResourceRequests(null); // Register with containerAllocationExpirer. container.containerAllocationExpirer.register(container.getContainerId()); // Tell the app container.eventHandler.handle(new RMAppRunningOnNodeEvent(container .getApplicationAttemptId().getApplicationId(), container.nodeId)); } }
@Override public void transition(RMContainerImpl container, RMContainerEvent event) { // Clear ResourceRequest stored in RMContainer container.setResourceRequests(null); // Register with containerAllocationExpirer. container.containerAllocationExpirer.register(container.getContainerId()); // Tell the app container.eventHandler.handle(new RMAppRunningOnNodeEvent(container .getApplicationAttemptId().getApplicationId(), container.nodeId)); } }
@Override public void transition(RMContainerImpl container, RMContainerEvent event) { // Clear ResourceRequest stored in RMContainer, we don't need to remember // this anymore. container.setContainerRequest(null); // Register with containerAllocationExpirer. container.containerAllocationExpirer.register( new AllocationExpirationInfo(container.getContainerId())); // Tell the app container.eventHandler.handle(new RMAppRunningOnNodeEvent(container .getApplicationAttemptId().getApplicationId(), container.nodeId)); publishNonAMContainerEventstoATS(container); } }
private void testUnmanagedAMSuccess(String url) { unmanagedAM = true; when(submissionContext.getUnmanagedAM()).thenReturn(true); // submit AM and check it goes to LAUNCHED state scheduleApplicationAttempt(); testAppAttemptLaunchedState(null); verify(amLivelinessMonitor, times(1)).register( applicationAttempt.getAppAttemptId()); // launch AM runApplicationAttempt(null, "host", 8042, url, true); // complete a container Container container = mock(Container.class); when(container.getNodeId()).thenReturn(NodeId.newInstance("host", 1234)); application.handle(new RMAppRunningOnNodeEvent(application.getApplicationId(), container.getNodeId())); applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent( applicationAttempt.getAppAttemptId(), mock(ContainerStatus.class), container.getNodeId())); // complete AM String diagnostics = "Successful"; FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED; applicationAttempt.handle(new RMAppAttemptUnregistrationEvent( applicationAttempt.getAppAttemptId(), url, finalStatus, diagnostics)); testAppAttemptFinishedState(null, finalStatus, url, diagnostics, 1, true); assertFalse(transferStateFromPreviousAttempt); }
when(container1.getNodeId()).thenReturn(NodeId.newInstance("host", 1234)); application.handle(new RMAppRunningOnNodeEvent(application .getApplicationId(), container1.getNodeId()));
when(container1.getNodeId()).thenReturn(NodeId.newInstance("host", 1234)); application.handle(new RMAppRunningOnNodeEvent(application .getApplicationId(), container1.getNodeId()));
@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 testUnmanagedAMSuccess(String url) { unmanagedAM = true; when(submissionContext.getUnmanagedAM()).thenReturn(true); // submit AM and check it goes to LAUNCHED state scheduleApplicationAttempt(); testAppAttemptLaunchedState(null, RMAppAttemptState.LAUNCHED); verify(amLivelinessMonitor, times(1)).register( applicationAttempt.getAppAttemptId()); // launch AM runApplicationAttempt(null, "host", 8042, url, true); // complete a container Container container = mock(Container.class); when(container.getNodeId()).thenReturn(NodeId.newInstance("host", 1234)); application.handle(new RMAppRunningOnNodeEvent(application.getApplicationId(), container.getNodeId())); applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent( applicationAttempt.getAppAttemptId(), mock(ContainerStatus.class), container.getNodeId())); // complete AM String diagnostics = "Successful"; FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED; applicationAttempt.handle(new RMAppAttemptUnregistrationEvent( applicationAttempt.getAppAttemptId(), url, finalStatus, diagnostics)); sendAttemptUpdateSavedEvent(applicationAttempt); testAppAttemptFinishedState(null, finalStatus, url, diagnostics, 1, true); assertFalse(transferStateFromPreviousAttempt); }
@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; } } }
} else if (report.getContainerState().equals(ContainerState.RUNNING)) { container.eventHandler.handle(new RMAppRunningOnNodeEvent(container .getApplicationAttemptId().getApplicationId(), container.nodeId)); return RMContainerState.RUNNING;
new RMNodeImpl(nodeId1, rmContext, null, 0, 0, null, capability, null); node1.handle(new RMNodeStartedEvent(nodeId1, null, null)); rmApp.handle(new RMAppRunningOnNodeEvent(this.appId, nodeId1)); new RMNodeImpl(nodeId2, rmContext, null, 0, 0, null, capability, null); node2.handle(new RMNodeStartedEvent(node2.getNodeID(), null, null)); rmApp.handle(new RMAppRunningOnNodeEvent(this.appId, nodeId2));