/** * Wait until an app removed from scheduler. * The timeout is 40 seconds. * @param appId the id of an app * @throws InterruptedException * if interrupted while waiting for app removed */ public void waitForAppRemovedFromScheduler(ApplicationId appId) throws InterruptedException { int timeWaiting = 0; drainEventsImplicitly(); Map<ApplicationId, SchedulerApplication> apps = ((AbstractYarnScheduler) getResourceScheduler()) .getSchedulerApplications(); while (apps.containsKey(appId)) { if (timeWaiting >= TIMEOUT_MS_FOR_APP_REMOVED) { break; } LOG.info("wait for app removed, " + appId); Thread.sleep(WAIT_MS_PER_LOOP); timeWaiting += WAIT_MS_PER_LOOP; } Assert.assertTrue("app is not removed from scheduler (timeout).", !apps.containsKey(appId)); LOG.info("app is removed from scheduler, " + appId); }
@Test public void testAddAndRemoveAppFromFairScheduler() throws Exception { AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode> scheduler = (AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) resourceManager .getResourceScheduler(); TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler( scheduler.getSchedulerApplications(), scheduler, "default"); }
@Test public void testAddAndRemoveAppFromFairScheduler() throws Exception { AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode> scheduler = (AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) resourceManager .getResourceScheduler(); TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler( scheduler.getSchedulerApplications(), scheduler, "default"); }
@Test public void testAddAndRemoveAppFromFiFoScheduler() throws Exception { Configuration conf = new Configuration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class, ResourceScheduler.class); MockRM rm = new MockRM(conf); @SuppressWarnings("unchecked") AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode> fs = (AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) rm .getResourceScheduler(); TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler( fs.getSchedulerApplications(), fs, "queue"); }
@SuppressWarnings("static-access") public void clearQueueMetrics(RMApp app) { ((AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) getResourceScheduler()) .getSchedulerApplications().get(app.getApplicationId()).getQueue() .getMetrics().clearQueueMetrics(); }
@SuppressWarnings("static-access") public void clearQueueMetrics(RMApp app) { ((AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) getResourceScheduler()) .getSchedulerApplications().get(app.getApplicationId()).getQueue() .getMetrics().clearQueueMetrics(); }
@Test public void testAddAndRemoveAppFromFiFoScheduler() throws Exception { Configuration conf = new Configuration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class, ResourceScheduler.class); MockRM rm = new MockRM(conf); @SuppressWarnings("unchecked") AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode> fs = (AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) rm .getResourceScheduler(); TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler( fs.getSchedulerApplications(), fs, "queue"); }
am1.allocate(null, Arrays.asList(runningContainer)); Map schedulerApplications = scheduler.getSchedulerApplications(); SchedulerApplication schedulerApp = (SchedulerApplication) scheduler.getSchedulerApplications().get( app.getApplicationId()); schedulerApplications.put(mockAPp.getApplicationId(), application);
@Test public void testAddAndRemoveAppFromCapacityScheduler() throws Exception { CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); setupQueueConfiguration(conf); conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class); MockRM rm = new MockRM(conf); @SuppressWarnings("unchecked") AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode> cs = (AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) rm .getResourceScheduler(); SchedulerApplication<SchedulerApplicationAttempt> app = TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler( cs.getSchedulerApplications(), cs, "a1"); Assert.assertEquals("a1", app.getQueue().getQueueName()); }
@Test public void testAddAndRemoveAppFromCapacityScheduler() throws Exception { CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); setupQueueConfiguration(conf); conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class); MockRM rm = new MockRM(conf); @SuppressWarnings("unchecked") AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode> cs = (AbstractYarnScheduler<SchedulerApplicationAttempt, SchedulerNode>) rm .getResourceScheduler(); SchedulerApplication<SchedulerApplicationAttempt> app = TestSchedulerUtils.verifyAppAddedAndRemovedFromScheduler( cs.getSchedulerApplications(), cs, "a1"); Assert.assertEquals("a1", app.getQueue().getQueueName()); }
.getSchedulerApplications(); SchedulerApplication schedulerApp = schedulerApps.get(recoveredApp.getApplicationId());
.getSchedulerApplications(); SchedulerApplication<SchedulerApplicationAttempt> schedulerApp = sa.get( recoveredApp1.getApplicationId());
.getSchedulerApplications(); SchedulerApplication schedulerApp = schedulerApps.get(recoveredApp1.getApplicationId());
.getSchedulerApplications(); SchedulerApplication<SchedulerApplicationAttempt> schedulerApp = sa.get(recoveredApp1.getApplicationId());
.getSchedulerApplications(); SchedulerApplication schedulerApp = schedulerApps.get(recoveredApp1.getApplicationId());
.getSchedulerApplications(); SchedulerApplication schedulerApp1_1 = schedulerApps.get(app1_1.getApplicationId());
.getSchedulerApplications(); SchedulerApplication schedulerApp1_1 = schedulerApps.get(app1_1.getApplicationId());