diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index c90674e5a6..a3954e06a9 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -626,6 +626,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 diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java index 06d282df14..f1d0f9c809 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java @@ -551,8 +551,15 @@ private void validateExistingQueues( // check that all static queues are included in the newQueues list for (Map.Entry 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."); } } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueParsing.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueParsing.java index 8d04700690..198bd4a27b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueParsing.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestQueueParsing.java @@ -865,4 +865,37 @@ public void testQueueParsingWithSumOfChildLabelCapacityNot100PercentWithWildCard 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); + } }