|
@@ -4417,4 +4417,44 @@ public class TestCapacityScheduler {
|
|
|
Assert.assertEquals(b1.getState(), QueueState.RUNNING);
|
|
|
Assert.assertTrue(!b1.getChildQueues().isEmpty());
|
|
|
}
|
|
|
+
|
|
|
+ @Test(timeout = 30000)
|
|
|
+ public void testAMLimitDouble() throws Exception {
|
|
|
+ CapacitySchedulerConfiguration config =
|
|
|
+ new CapacitySchedulerConfiguration();
|
|
|
+ config.set(CapacitySchedulerConfiguration.RESOURCE_CALCULATOR_CLASS,
|
|
|
+ DominantResourceCalculator.class.getName());
|
|
|
+ CapacitySchedulerConfiguration conf =
|
|
|
+ new CapacitySchedulerConfiguration(config);
|
|
|
+ conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
|
|
|
+ ResourceScheduler.class);
|
|
|
+ conf.setInt("yarn.scheduler.minimum-allocation-mb", 512);
|
|
|
+ conf.setInt("yarn.scheduler.minimum-allocation-vcores", 1);
|
|
|
+ MockRM rm = new MockRM(conf);
|
|
|
+ rm.start();
|
|
|
+ rm.registerNode("127.0.0.1:1234", 10 * GB);
|
|
|
+ rm.registerNode("127.0.0.1:1235", 10 * GB);
|
|
|
+ rm.registerNode("127.0.0.1:1236", 10 * GB);
|
|
|
+ rm.registerNode("127.0.0.1:1237", 10 * GB);
|
|
|
+ ResourceScheduler scheduler = rm.getRMContext().getScheduler();
|
|
|
+ waitforNMRegistered(scheduler, 4, 5);
|
|
|
+ LeafQueue queueA =
|
|
|
+ (LeafQueue) ((CapacityScheduler) scheduler).getQueue("default");
|
|
|
+ Resource amResourceLimit = queueA.getAMResourceLimit();
|
|
|
+ Assert.assertEquals(4096, amResourceLimit.getMemorySize());
|
|
|
+ Assert.assertEquals(4, amResourceLimit.getVirtualCores());
|
|
|
+ rm.stop();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void waitforNMRegistered(ResourceScheduler scheduler, int nodecount,
|
|
|
+ int timesec) throws InterruptedException {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
+ while (System.currentTimeMillis() - start < timesec * 1000) {
|
|
|
+ if (scheduler.getNumClusterNodes() < nodecount) {
|
|
|
+ Thread.sleep(100);
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|