public static SchedulerApplication<SchedulerApplicationAttempt> verifyAppAddedAndRemovedFromScheduler( Map<ApplicationId, SchedulerApplication<SchedulerApplicationAttempt>> applications, EventHandler<SchedulerEvent> handler, String queueName) { ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1); AppAddedSchedulerEvent appAddedEvent = new AppAddedSchedulerEvent(appId, queueName, "user"); handler.handle(appAddedEvent); SchedulerApplication<SchedulerApplicationAttempt> app = applications.get(appId); // verify application is added. Assert.assertNotNull(app); Assert.assertEquals("user", app.getUser()); AppRemovedSchedulerEvent appRemoveEvent = new AppRemovedSchedulerEvent(appId, RMAppState.FINISHED); handler.handle(appRemoveEvent); Assert.assertNull(applications.get(appId)); return app; }
removeApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState()); break; case NODE_RESOURCE_UPDATE:
private void verifyAppRemovedSchedulerEvent(RMAppState finalState) { Assert.assertEquals(SchedulerEventType.APP_REMOVED, schedulerDispatcher.lastSchedulerEvent.getType()); if(schedulerDispatcher.lastSchedulerEvent instanceof AppRemovedSchedulerEvent) { AppRemovedSchedulerEvent appRemovedEvent = (AppRemovedSchedulerEvent) schedulerDispatcher.lastSchedulerEvent; Assert.assertEquals(finalState, appRemovedEvent.getFinalState()); } }
AppRemovedSchedulerEvent appRemoveEvent = (AppRemovedSchedulerEvent) schedulerEvent; appQueueMap.remove(appRemoveEvent.getApplicationID()); } else if (schedulerEvent.getType() == SchedulerEventType.APP_ADDED && schedulerEvent instanceof AppAddedSchedulerEvent) {
private void verifyAppRemovedSchedulerEvent(RMAppState finalState) { Assert.assertEquals(SchedulerEventType.APP_REMOVED, schedulerDispatcher.lastSchedulerEvent.getType()); if(schedulerDispatcher.lastSchedulerEvent instanceof AppRemovedSchedulerEvent) { AppRemovedSchedulerEvent appRemovedEvent = (AppRemovedSchedulerEvent) schedulerDispatcher.lastSchedulerEvent; Assert.assertEquals(finalState, appRemovedEvent.getFinalState()); } } }
removeApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState()); break; case NODE_RESOURCE_UPDATE:
public static SchedulerApplication<SchedulerApplicationAttempt> verifyAppAddedAndRemovedFromScheduler( Map<ApplicationId, SchedulerApplication<SchedulerApplicationAttempt>> applications, EventHandler<SchedulerEvent> handler, String queueName) throws Exception { ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1); AppAddedSchedulerEvent appAddedEvent = new AppAddedSchedulerEvent(appId, queueName, "user"); handler.handle(appAddedEvent); SchedulerApplication<SchedulerApplicationAttempt> app = applications.get(appId); // verify application is added. Assert.assertNotNull(app); Assert.assertEquals("user", app.getUser()); AppRemovedSchedulerEvent appRemoveEvent = new AppRemovedSchedulerEvent(appId, RMAppState.FINISHED); handler.handle(appRemoveEvent); Assert.assertNull(applications.get(appId)); return app; }
removeApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState()); break; case NODE_RESOURCE_UPDATE:
public void transition(RMAppImpl app, RMAppEvent event) { for (NodeId nodeId : app.getRanNodes()) { app.handler.handle( new RMNodeCleanAppEvent(nodeId, app.applicationId)); } app.finishTime = app.storedFinishTime; if (app.finishTime == 0 ) { app.finishTime = app.systemClock.getTime(); } // Recovered apps that are completed were not added to scheduler, so no // need to remove them from scheduler. if (app.recoveredFinalState == null) { app.handler.handle(new AppRemovedSchedulerEvent(app.applicationId, finalState)); } app.handler.handle( new RMAppManagerEvent(app.applicationId, RMAppManagerEventType.APP_COMPLETED)); app.rmContext.getRMApplicationHistoryWriter() .applicationFinished(app, finalState); app.rmContext.getSystemMetricsPublisher() .appFinished(app, finalState, app.finishTime); }; }
doneApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState());
public void transition(RMAppImpl app, RMAppEvent event) { for (NodeId nodeId : app.getRanNodes()) { app.handler.handle( new RMNodeCleanAppEvent(nodeId, app.applicationId)); } app.finishTime = app.storedFinishTime; if (app.finishTime == 0 ) { app.finishTime = app.systemClock.getTime(); } // Recovered apps that are completed were not added to scheduler, so no // need to remove them from scheduler. if (app.recoveredFinalState == null) { app.handler.handle(new AppRemovedSchedulerEvent(app.applicationId, finalState)); } app.handler.handle( new RMAppManagerEvent(app.applicationId, RMAppManagerEventType.APP_COMPLETED)); app.rmContext.getRMApplicationHistoryWriter() .applicationFinished(app, finalState); app.rmContext.getSystemMetricsPublisher() .appFinished(app, finalState, app.finishTime); }; }
doneApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState());
public void transition(RMAppImpl app, RMAppEvent event) { app.logAggregationStartTime = app.systemClock.getTime(); for (NodeId nodeId : app.getRanNodes()) { app.handler.handle( new RMNodeCleanAppEvent(nodeId, app.applicationId)); } app.finishTime = app.storedFinishTime; if (app.finishTime == 0 ) { app.finishTime = app.systemClock.getTime(); } // Recovered apps that are completed were not added to scheduler, so no // need to remove them from scheduler. if (app.recoveredFinalState == null) { app.handler.handle(new AppRemovedSchedulerEvent(app.applicationId, finalState)); } app.handler.handle( new RMAppManagerEvent(app.applicationId, RMAppManagerEventType.APP_COMPLETED)); app.rmContext.getRMApplicationHistoryWriter() .applicationFinished(app, finalState); app.rmContext.getSystemMetricsPublisher() .appFinished(app, finalState, app.finishTime); // set the memory free app.clearUnusedFields(); appAdminClientCleanUp(app); }; }
doneApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState());
RMAppAttemptState.FINISHED, false); cs.handle(event); AppRemovedSchedulerEvent rEvent = new AppRemovedSchedulerEvent( appAttemptId_0.getApplicationId(), RMAppState.FINISHED); cs.handle(rEvent);
doneApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState());
RMAppAttemptState.FINISHED, false); cs.handle(event); AppRemovedSchedulerEvent rEvent = new AppRemovedSchedulerEvent( appAttemptId_0.getApplicationId(), RMAppState.FINISHED); cs.handle(rEvent);
doneApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState());
doneApplication(appRemovedEvent.getApplicationID(), appRemovedEvent.getFinalState());