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/fair/converter/weightconversion/WeightToWeightConverter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/weightconversion/WeightToWeightConverter.java index 6dcd05ce702..cbc98e41a53 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/weightconversion/WeightToWeightConverter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/weightconversion/WeightToWeightConverter.java @@ -28,6 +28,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSQueue; public class WeightToWeightConverter implements CapacityConverter { + private static final String ROOT_QUEUE = "root"; @Override public void convertWeightsForChildQueues(FSQueue queue, @@ -35,6 +36,10 @@ public class WeightToWeightConverter List children = queue.getChildQueues(); if (queue instanceof FSParentQueue || !children.isEmpty()) { + if (queue.getName().equals(ROOT_QUEUE)) { + csConfig.set(getProperty(queue), getWeightString(queue)); + } + children.forEach(fsQueue -> csConfig.set( getProperty(fsQueue), getWeightString(fsQueue))); csConfig.setBoolean(getAutoCreateV2EnabledProperty(queue), true); 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/fair/converter/weightconversion/TestWeightToWeightConverter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/weightconversion/TestWeightToWeightConverter.java index 5f9b2d00515..28eb2b662c9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/weightconversion/TestWeightToWeightConverter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/weightconversion/TestWeightToWeightConverter.java @@ -44,7 +44,9 @@ public class TestWeightToWeightConverter extends WeightConverterTestBase { FSQueue root = createFSQueues(); converter.convertWeightsForChildQueues(root, config); - assertEquals("Converted items", 1, + assertEquals("root weight", "1.0w", + config.get(PREFIX + "root.capacity")); + assertEquals("Converted items", 2, config.getPropsWithPrefix(PREFIX).size()); } @@ -53,9 +55,11 @@ public class TestWeightToWeightConverter extends WeightConverterTestBase { FSQueue root = createFSQueues(1); converter.convertWeightsForChildQueues(root, config); + assertEquals("root weight", "1.0w", + config.get(PREFIX + "root.capacity")); assertEquals("root.a weight", "1.0w", config.get(PREFIX + "root.a.capacity")); - assertEquals("Number of properties", 2, + assertEquals("Number of properties", 3, config.getPropsWithPrefix(PREFIX).size()); } @@ -65,8 +69,10 @@ public class TestWeightToWeightConverter extends WeightConverterTestBase { converter.convertWeightsForChildQueues(root, config); - assertEquals("Number of properties", 4, + assertEquals("Number of properties", 5, config.getPropsWithPrefix(PREFIX).size()); + assertEquals("root weight", "1.0w", + config.get(PREFIX + "root.capacity")); assertEquals("root.a weight", "1.0w", config.get(PREFIX + "root.a.capacity")); assertEquals("root.b weight", "2.0w", @@ -90,7 +96,7 @@ public class TestWeightToWeightConverter extends WeightConverterTestBase { FSQueue root = createParent(new ArrayList<>()); converter.convertWeightsForChildQueues(root, config); - assertEquals("Number of properties", 1, + assertEquals("Number of properties", 2, config.getPropsWithPrefix(PREFIX).size()); assertTrue("root autocreate v2 enabled", config.getBoolean(PREFIX + "root.auto-queue-creation-v2.enabled",