private void removeCompletedApps(DecommissioningNodeContext context) { Iterator<ApplicationId> it = context.appIds.iterator(); while (it.hasNext()) { ApplicationId appId = it.next(); RMApp rmApp = rmContext.getRMApps().get(appId); if (rmApp == null) { LOG.debug("Consider non-existing app " + appId + " as completed"); it.remove(); continue; } if (rmApp.getState() == RMAppState.FINISHED || rmApp.getState() == RMAppState.FAILED || rmApp.getState() == RMAppState.KILLED) { LOG.debug("Remove " + rmApp.getState() + " app " + appId); it.remove(); } } }
public static boolean isAppInFinalState(RMApp rmApp) { RMAppState appState = ((RMAppImpl) rmApp).getRecoveredFinalState(); if (appState == null) { appState = rmApp.getState(); } return appState == RMAppState.FAILED || appState == RMAppState.FINISHED || appState == RMAppState.KILLED; }
public static boolean isAppInFinalState(RMApp rmApp) { RMAppState appState = ((RMAppImpl) rmApp).getRecoveredFinalState(); if (appState == null) { appState = rmApp.getState(); } return appState == RMAppState.FAILED || appState == RMAppState.FINISHED || appState == RMAppState.KILLED; }
public static boolean isAppInFinalState(RMApp rmApp) { RMAppState appState = ((RMAppImpl) rmApp).getRecoveredFinalState(); if (appState == null) { appState = rmApp.getState(); } return appState == RMAppState.FAILED || appState == RMAppState.FINISHED || appState == RMAppState.KILLED; }
@Inject public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx, Configuration conf) { super(ctx); FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler(); fsinfo = new FairSchedulerInfo(scheduler); apps = new ConcurrentHashMap<ApplicationId, RMApp>(); for (Map.Entry<ApplicationId, RMApp> entry : rm.getRMContext().getRMApps() .entrySet()) { if (!(RMAppState.NEW.equals(entry.getValue().getState()) || RMAppState.NEW_SAVING.equals(entry.getValue().getState()) || RMAppState.SUBMITTED.equals(entry.getValue().getState()))) { apps.put(entry.getKey(), entry.getValue()); } } this.conf = conf; this.rm = rm; }
@Inject public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx, Configuration conf) { super(ctx); FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler(); fsinfo = new FairSchedulerInfo(scheduler); apps = new ConcurrentHashMap<ApplicationId, RMApp>(); for (Map.Entry<ApplicationId, RMApp> entry : rm.getRMContext().getRMApps() .entrySet()) { if (!(RMAppState.NEW.equals(entry.getValue().getState()) || RMAppState.NEW_SAVING.equals(entry.getValue().getState()) || RMAppState.SUBMITTED.equals(entry.getValue().getState()))) { apps.put(entry.getKey(), entry.getValue()); } } this.conf = conf; this.rm = rm; }
@Inject public FairSchedulerAppsBlock(ResourceManager rm, ViewContext ctx, Configuration conf) { super(ctx); FairScheduler scheduler = (FairScheduler) rm.getResourceScheduler(); fsinfo = new FairSchedulerInfo(scheduler); apps = new ConcurrentHashMap<ApplicationId, RMApp>(); for (Map.Entry<ApplicationId, RMApp> entry : rm.getRMContext().getRMApps() .entrySet()) { if (!(RMAppState.NEW.equals(entry.getValue().getState()) || RMAppState.NEW_SAVING.equals(entry.getValue().getState()) || RMAppState.SUBMITTED.equals(entry.getValue().getState()))) { apps.put(entry.getKey(), entry.getValue()); } } this.conf = conf; this.rm = rm; }
protected void addToCompletedApps(TestRMAppManager appMonitor, RMContext rmContext) { for (RMApp app : rmContext.getRMApps().values()) { if (app.getState() == RMAppState.FINISHED || app.getState() == RMAppState.KILLED || app.getState() == RMAppState.FAILED) { appMonitor.finishApplication(app.getApplicationId()); } } }
private static void assertAppState(RMAppState state, RMApp application) { Assert.assertEquals("application state should have been " + state, state, application.getState()); }
private static void assertAppState(RMAppState state, RMApp application) { Assert.assertEquals("application state should have been " + state, state, application.getState()); }
public void waitForState(ApplicationId appId, RMAppState finalState) throws Exception { RMApp app = getRMContext().getRMApps().get(appId); Assert.assertNotNull("app shouldn't be null", app); int timeoutSecs = 0; while (!finalState.equals(app.getState()) && timeoutSecs++ < 40) { System.out.println("App : " + appId + " State is : " + app.getState() + " Waiting for state : " + finalState); Thread.sleep(2000); } System.out.println("App State is : " + app.getState()); Assert.assertEquals("App state is not correct (timedout)", finalState, app.getState()); }
private void addToCompletedApps(TestRMAppManager appMonitor, RMContext rmContext) { // ensure applications are finished in order by their IDs List<RMApp> sortedApps = new ArrayList<>(rmContext.getRMApps().values()); sortedApps.sort(Comparator.comparingInt(o -> o.getApplicationId().getId())); for (RMApp app : sortedApps) { if (app.getState() == RMAppState.FINISHED || app.getState() == RMAppState.KILLED || app.getState() == RMAppState.FAILED) { appMonitor.finishApplication(app.getApplicationId()); } } }
private void failOverAndKillApp(ApplicationId appId, ApplicationAttemptId appAttemptId, RMAppState initialRMAppState, RMAppAttemptState initialRMAppAttemptState, RMAppState expectedAppStateBeforeKillApp) throws Exception { Assert.assertEquals(initialRMAppState, rm1.getRMContext().getRMApps().get(appId).getState()); Assert.assertEquals(initialRMAppAttemptState, rm1.getRMContext() .getRMApps().get(appId).getAppAttempts().get(appAttemptId).getState()); explicitFailover(); Assert.assertEquals(expectedAppStateBeforeKillApp, rm2.getRMContext().getRMApps().get(appId).getState()); killApplication(rm2, appId, appAttemptId, initialRMAppState); }
private void failOverAndKillApp(ApplicationId appId, ApplicationAttemptId appAttemptId, RMAppState initialRMAppState, RMAppAttemptState initialRMAppAttemptState, RMAppState expectedAppStateBeforeKillApp) throws Exception { Assert.assertEquals(initialRMAppState, rm1.getRMContext().getRMApps().get(appId).getState()); Assert.assertEquals(initialRMAppAttemptState, rm1.getRMContext() .getRMApps().get(appId).getAppAttempts().get(appAttemptId).getState()); explicitFailover(); Assert.assertEquals(expectedAppStateBeforeKillApp, rm2.getRMContext().getRMApps().get(appId).getState()); killApplication(rm2, appId, appAttemptId, initialRMAppState); }
private void failOverAndKillApp(ApplicationId appId, RMAppState initialRMAppState) throws Exception { Assert.assertEquals(initialRMAppState, rm1.getRMContext().getRMApps().get(appId).getState()); explicitFailover(); Assert.assertTrue(rm2.getRMContext().getRMApps().get(appId) == null); killApplication(rm2, appId, null, initialRMAppState); }
private void failOverAndKillApp(ApplicationId appId, RMAppState initialRMAppState) throws Exception { Assert.assertEquals(initialRMAppState, rm1.getRMContext().getRMApps().get(appId).getState()); explicitFailover(); Assert.assertTrue(rm2.getRMContext().getRMApps().get(appId) == null); killApplication(rm2, appId, null, initialRMAppState); }
@Test public void testRMAppSubmit() throws Exception { appMonitor.submitApplication(asContext, "test"); RMApp app = rmContext.getRMApps().get(appId); Assert.assertNotNull("app is null", app); Assert.assertEquals("app id doesn't match", appId, app.getApplicationId()); Assert.assertEquals("app state doesn't match", RMAppState.NEW, app.getState()); verify(metricsPublisher).appACLsUpdated( any(RMApp.class), any(String.class), anyLong()); // wait for event to be processed int timeoutSecs = 0; while ((getAppEventType() == RMAppEventType.KILL) && timeoutSecs++ < 20) { Thread.sleep(1000); } Assert.assertEquals("app event type sent is wrong", RMAppEventType.START, getAppEventType()); }
private RMApp testRMAppSubmit() throws Exception { appMonitor.submitApplication(asContext, "test"); RMApp app = rmContext.getRMApps().get(appId); Assert.assertNotNull("app is null", app); Assert.assertEquals("app id doesn't match", appId, app.getApplicationId()); Assert.assertEquals("app state doesn't match", RMAppState.NEW, app.getState()); // wait for event to be processed int timeoutSecs = 0; while ((getAppEventType() == RMAppEventType.KILL) && timeoutSecs++ < 20) { Thread.sleep(1000); } Assert.assertEquals("app event type sent is wrong", RMAppEventType.START, getAppEventType()); return app; }
@Test(timeout = 10000) public void testAutoCreateLeafQueueFailsWithNoQueueMapping() throws Exception { final String INVALID_USER = "invalid_user"; // submit an app under a different queue name which does not exist // and queue mapping does not exist for this user RMApp app = mockRM.submitApp(GB, "app", INVALID_USER, null, INVALID_USER, false); mockRM.drainEvents(); mockRM.waitForState(app.getApplicationId(), RMAppState.FAILED); assertEquals(RMAppState.FAILED, app.getState()); }
@Test (timeout = 30000) public void testRMAppSubmitDuplicateApplicationId() throws Exception { ApplicationId appId = MockApps.newAppID(0); asContext.setApplicationId(appId); RMApp appOrig = rmContext.getRMApps().get(appId); Assert.assertTrue("app name matches but shouldn't", "testApp1" != appOrig.getName()); // our testApp1 should be rejected and original app with same id should be left in place try { appMonitor.submitApplication(asContext, "test"); Assert.fail("Exception is expected when applicationId is duplicate."); } catch (YarnException e) { Assert.assertTrue("The thrown exception is not the expectd one.", e.getMessage().contains("Cannot add a duplicate!")); } // make sure original app didn't get removed RMApp app = rmContext.getRMApps().get(appId); Assert.assertNotNull("app is null", app); Assert.assertEquals("app id doesn't match", appId, app.getApplicationId()); Assert.assertEquals("app state doesn't match", RMAppState.FINISHED, app.getState()); }