|
@@ -470,6 +470,52 @@ public class TestCapacityScheduler {
|
|
return conf;
|
|
return conf;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @param conf, to be modified
|
|
|
|
+ * @return, CS configuration which has converted b1 to parent queue
|
|
|
|
+ * root
|
|
|
|
+ * / \
|
|
|
|
+ * a b
|
|
|
|
+ * / \ / | \
|
|
|
|
+ * a1 a2 b1 b2 b3
|
|
|
|
+ * |
|
|
|
|
+ * b11
|
|
|
|
+ */
|
|
|
|
+ private CapacitySchedulerConfiguration
|
|
|
|
+ setupQueueConfigurationWithB1AsParentQueue(
|
|
|
|
+ CapacitySchedulerConfiguration conf) {
|
|
|
|
+
|
|
|
|
+ // Define top-level queues
|
|
|
|
+ conf.setQueues(CapacitySchedulerConfiguration.ROOT,
|
|
|
|
+ new String[] { "a", "b" });
|
|
|
|
+
|
|
|
|
+ conf.setCapacity(A, A_CAPACITY);
|
|
|
|
+ conf.setCapacity(B, B_CAPACITY);
|
|
|
|
+
|
|
|
|
+ // Define 2nd-level queues
|
|
|
|
+ conf.setQueues(A, new String[] { "a1", "a2" });
|
|
|
|
+ conf.setCapacity(A1, A1_CAPACITY);
|
|
|
|
+ conf.setUserLimitFactor(A1, 100.0f);
|
|
|
|
+ conf.setCapacity(A2, A2_CAPACITY);
|
|
|
|
+ conf.setUserLimitFactor(A2, 100.0f);
|
|
|
|
+
|
|
|
|
+ conf.setQueues(B, new String[] {"b1","b2", "b3"});
|
|
|
|
+ conf.setCapacity(B1, B1_CAPACITY);
|
|
|
|
+ conf.setUserLimitFactor(B1, 100.0f);
|
|
|
|
+ conf.setCapacity(B2, B2_CAPACITY);
|
|
|
|
+ conf.setUserLimitFactor(B2, 100.0f);
|
|
|
|
+ conf.setCapacity(B3, B3_CAPACITY);
|
|
|
|
+ conf.setUserLimitFactor(B3, 100.0f);
|
|
|
|
+
|
|
|
|
+ // Set childQueue for B1
|
|
|
|
+ conf.setQueues(B1, new String[] {"b11"});
|
|
|
|
+ String B11 = B1 + ".b11";
|
|
|
|
+ conf.setCapacity(B11, 100.0f);
|
|
|
|
+ conf.setUserLimitFactor(B11, 100.0f);
|
|
|
|
+
|
|
|
|
+ return conf;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @param conf, to be modified
|
|
* @param conf, to be modified
|
|
* @return, CS configuration which has deleted a
|
|
* @return, CS configuration which has deleted a
|
|
@@ -4140,4 +4186,61 @@ public class TestCapacityScheduler {
|
|
|
|
|
|
cs.stop();
|
|
cs.stop();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Test if we can convert a leaf queue to a parent queue
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @Test (timeout = 10000)
|
|
|
|
+ public void testConvertLeafQueueToParentQueue() throws Exception {
|
|
|
|
+ CapacityScheduler cs = new CapacityScheduler();
|
|
|
|
+ CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration();
|
|
|
|
+ RMContextImpl rmContext = new RMContextImpl(null, null, null, null, null,
|
|
|
|
+ null, new RMContainerTokenSecretManager(conf),
|
|
|
|
+ new NMTokenSecretManagerInRM(conf),
|
|
|
|
+ new ClientToAMTokenSecretManagerInRM(), null);
|
|
|
|
+ setupQueueConfiguration(conf);
|
|
|
|
+ cs.setConf(new YarnConfiguration());
|
|
|
|
+ cs.setRMContext(resourceManager.getRMContext());
|
|
|
|
+ cs.init(conf);
|
|
|
|
+ cs.start();
|
|
|
|
+ cs.reinitialize(conf, rmContext);
|
|
|
|
+ checkQueueCapacities(cs, A_CAPACITY, B_CAPACITY);
|
|
|
|
+
|
|
|
|
+ String targetQueue = "b1";
|
|
|
|
+ CSQueue b1 = cs.getQueue(targetQueue);
|
|
|
|
+ Assert.assertEquals(b1.getState(), QueueState.RUNNING);
|
|
|
|
+
|
|
|
|
+ // test if we can convert a leaf queue which is in RUNNING state
|
|
|
|
+ conf = new CapacitySchedulerConfiguration();
|
|
|
|
+ setupQueueConfigurationWithB1AsParentQueue(conf);
|
|
|
|
+ try {
|
|
|
|
+ cs.reinitialize(conf, mockContext);
|
|
|
|
+ fail("Expected to throw exception when refresh queue tries to convert"
|
|
|
|
+ + " a child queue to a parent queue.");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ // ignore
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // now set queue state for b1 to STOPPED
|
|
|
|
+ conf = new CapacitySchedulerConfiguration();
|
|
|
|
+ setupQueueConfiguration(conf);
|
|
|
|
+ conf.set("yarn.scheduler.capacity.root.b.b1.state", "STOPPED");
|
|
|
|
+ cs.reinitialize(conf, mockContext);
|
|
|
|
+ Assert.assertEquals(b1.getState(), QueueState.STOPPED);
|
|
|
|
+
|
|
|
|
+ // test if we can convert a leaf queue which is in STOPPED state
|
|
|
|
+ conf = new CapacitySchedulerConfiguration();
|
|
|
|
+ setupQueueConfigurationWithB1AsParentQueue(conf);
|
|
|
|
+ try {
|
|
|
|
+ cs.reinitialize(conf, mockContext);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ fail("Expected to NOT throw exception when refresh queue tries"
|
|
|
|
+ + " to convert a leaf queue WITHOUT running apps");
|
|
|
|
+ }
|
|
|
|
+ b1 = cs.getQueue(targetQueue);
|
|
|
|
+ Assert.assertTrue(b1 instanceof ParentQueue);
|
|
|
|
+ Assert.assertEquals(b1.getState(), QueueState.RUNNING);
|
|
|
|
+ Assert.assertTrue(!b1.getChildQueues().isEmpty());
|
|
|
|
+ }
|
|
}
|
|
}
|