From 6325e4b7dd1d447b60b64fcd582ec7fcb81601bd Mon Sep 17 00:00:00 2001 From: Jian He Date: Thu, 4 Jun 2015 10:52:07 -0700 Subject: [PATCH] YARN-3764. CapacityScheduler should forbid moving LeafQueue from one parent to another. Contributed by Wangda Tan (cherry picked from commit 6ad4e59cfc111a92747fdb1fb99cc6378044832a) --- hadoop-yarn-project/CHANGES.txt | 3 ++ .../scheduler/capacity/CapacityScheduler.java | 11 +++++-- .../scheduler/capacity/TestQueueParsing.java | 33 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 20402ca1ab3..71b68fe9b38 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -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 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 06d282df148..f1d0f9c8094 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 @@ public class CapacityScheduler extends // 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 8d04700690b..198bd4a27b5 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 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); + } }