YARN-3764. CapacityScheduler should forbid moving LeafQueue from one parent to another. Contributed by Wangda Tan

(cherry picked from commit 6ad4e59cfc)
This commit is contained in:
Jian He 2015-06-04 10:52:07 -07:00
parent f0f277ddd0
commit 6325e4b7dd
3 changed files with 45 additions and 2 deletions

View File

@ -582,6 +582,9 @@ Release 2.7.1 - UNRELEASED
YARN-3733. Fix DominantRC#compare() does not work as expected if
cluster resource is empty. (Rohith Sharmaks via wangda)
YARN-3764. CapacityScheduler should forbid moving LeafQueue from one parent
to another. (Wangda Tan via jianhe)
Release 2.7.0 - 2015-04-20
INCOMPATIBLE CHANGES

View File

@ -551,8 +551,15 @@ public class CapacityScheduler extends
// check that all static queues are included in the newQueues list
for (Map.Entry<String, CSQueue> e : queues.entrySet()) {
if (!(e.getValue() instanceof ReservationQueue)) {
if (!newQueues.containsKey(e.getKey())) {
throw new IOException(e.getKey() + " cannot be found during refresh!");
String queueName = e.getKey();
CSQueue oldQueue = e.getValue();
CSQueue newQueue = newQueues.get(queueName);
if (null == newQueue) {
throw new IOException(queueName + " cannot be found during refresh!");
} else if (!oldQueue.getQueuePath().equals(newQueue.getQueuePath())) {
throw new IOException(queueName + " is moved from:"
+ oldQueue.getQueuePath() + " to:" + newQueue.getQueuePath()
+ " after refresh, which is not allowed.");
}
}
}

View File

@ -865,4 +865,37 @@ public class TestQueueParsing {
capacityScheduler.start();
ServiceOperations.stopQuietly(capacityScheduler);
}
@Test(expected = IOException.class)
public void testQueueParsingWithMoveQueue()
throws IOException {
YarnConfiguration conf = new YarnConfiguration();
CapacitySchedulerConfiguration csConf =
new CapacitySchedulerConfiguration(conf);
csConf.setQueues("root", new String[] { "a" });
csConf.setQueues("root.a", new String[] { "x", "y" });
csConf.setCapacity("root.a", 100);
csConf.setCapacity("root.a.x", 50);
csConf.setCapacity("root.a.y", 50);
CapacityScheduler capacityScheduler = new CapacityScheduler();
RMContextImpl rmContext =
new RMContextImpl(null, null, null, null, null, null,
new RMContainerTokenSecretManager(csConf),
new NMTokenSecretManagerInRM(csConf),
new ClientToAMTokenSecretManagerInRM(), null);
rmContext.setNodeLabelManager(nodeLabelManager);
capacityScheduler.setConf(csConf);
capacityScheduler.setRMContext(rmContext);
capacityScheduler.init(csConf);
capacityScheduler.start();
csConf.setQueues("root", new String[] { "a", "x" });
csConf.setQueues("root.a", new String[] { "y" });
csConf.setCapacity("root.x", 50);
csConf.setCapacity("root.a", 50);
csConf.setCapacity("root.a.y", 100);
capacityScheduler.reinitialize(csConf, rmContext);
}
}