Skip to content

Commit fa15594

Browse files
committed
YARN-10600. Convert root queue in fs2cs weight mode conversion. Contributed by Benjamin Teke.
1 parent f565476 commit fa15594

File tree

2 files changed

+15
-4
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src

2 files changed

+15
-4
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@
2828

2929
public class WeightToWeightConverter
3030
implements CapacityConverter {
31+
private static final String ROOT_QUEUE = "root";
3132

3233
@Override
3334
public void convertWeightsForChildQueues(FSQueue queue,
3435
Configuration csConfig) {
3536
List<FSQueue> children = queue.getChildQueues();
3637

3738
if (queue instanceof FSParentQueue || !children.isEmpty()) {
39+
if (queue.getName().equals(ROOT_QUEUE)) {
40+
csConfig.set(getProperty(queue), getWeightString(queue));
41+
}
42+
3843
children.forEach(fsQueue -> csConfig.set(
3944
getProperty(fsQueue), getWeightString(fsQueue)));
4045
csConfig.setBoolean(getAutoCreateV2EnabledProperty(queue), true);

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public void testNoChildQueueConversion() {
4444
FSQueue root = createFSQueues();
4545
converter.convertWeightsForChildQueues(root, config);
4646

47-
assertEquals("Converted items", 1,
47+
assertEquals("root weight", "1.0w",
48+
config.get(PREFIX + "root.capacity"));
49+
assertEquals("Converted items", 2,
4850
config.getPropsWithPrefix(PREFIX).size());
4951
}
5052

@@ -53,9 +55,11 @@ public void testSingleWeightConversion() {
5355
FSQueue root = createFSQueues(1);
5456
converter.convertWeightsForChildQueues(root, config);
5557

58+
assertEquals("root weight", "1.0w",
59+
config.get(PREFIX + "root.capacity"));
5660
assertEquals("root.a weight", "1.0w",
5761
config.get(PREFIX + "root.a.capacity"));
58-
assertEquals("Number of properties", 2,
62+
assertEquals("Number of properties", 3,
5963
config.getPropsWithPrefix(PREFIX).size());
6064
}
6165

@@ -65,8 +69,10 @@ public void testMultiWeightConversion() {
6569

6670
converter.convertWeightsForChildQueues(root, config);
6771

68-
assertEquals("Number of properties", 4,
72+
assertEquals("Number of properties", 5,
6973
config.getPropsWithPrefix(PREFIX).size());
74+
assertEquals("root weight", "1.0w",
75+
config.get(PREFIX + "root.capacity"));
7076
assertEquals("root.a weight", "1.0w",
7177
config.get(PREFIX + "root.a.capacity"));
7278
assertEquals("root.b weight", "2.0w",
@@ -90,7 +96,7 @@ public void testAutoCreateV2FlagOnParentWithoutChildren() {
9096
FSQueue root = createParent(new ArrayList<>());
9197
converter.convertWeightsForChildQueues(root, config);
9298

93-
assertEquals("Number of properties", 1,
99+
assertEquals("Number of properties", 2,
94100
config.getPropsWithPrefix(PREFIX).size());
95101
assertTrue("root autocreate v2 enabled",
96102
config.getBoolean(PREFIX + "root.auto-queue-creation-v2.enabled",

0 commit comments

Comments
 (0)