Skip to content

Commit 3008014

Browse files
9uapawHarshitGupta11
authored andcommitted
YARN-11063. Support auto queue creation template wildcards for arbitrary queue depths. Contributed by Bence Kosztolnik.
1 parent b23c48e commit 3008014

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-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/capacity/AutoCreatedQueueTemplate.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public class AutoCreatedQueueTemplate {
4242
AUTO_QUEUE_CREATION_V2_PREFIX + "parent-template.";
4343

4444
private static final String WILDCARD_QUEUE = "*";
45-
private static final int MAX_WILDCARD_LEVEL = 1;
4645

4746
private final Map<String, String> templateProperties = new HashMap<>();
4847
private final Map<String, String> leafOnlyProperties = new HashMap<>();
@@ -86,7 +85,7 @@ public Map<String, String> getParentOnlyProperties() {
8685
/**
8786
* Sets the common template properties and parent specific template
8887
* properties of a child queue based on its parent template settings.
89-
* @param conf configuration to set
88+
* @param conf configuration to set
9089
* @param childQueuePath child queue path used for prefixing the properties
9190
*/
9291
public void setTemplateEntriesForChild(CapacitySchedulerConfiguration conf,
@@ -169,8 +168,8 @@ private void setTemplateConfigEntries(CapacitySchedulerConfiguration configurati
169168
// start with the most explicit format (without wildcard)
170169
int wildcardLevel = 0;
171170
// root can not be wildcarded
172-
// MAX_WILDCARD_LEVEL will be configurable in the future
173-
int supportedWildcardLevel = Math.min(queuePathMaxIndex, MAX_WILDCARD_LEVEL);
171+
int supportedWildcardLevel = Math.min(queuePathMaxIndex,
172+
configuration.getMaximumAutoCreatedQueueDepth(queuePath.getFullPath()));
174173
// Allow root to have template properties
175174
if (queuePath.isRoot()) {
176175
supportedWildcardLevel = 0;

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestAutoCreatedQueueTemplate.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ public void testOneLevelWildcardTemplate() {
6666

6767
}
6868

69+
@Test
70+
public void testTwoLevelWildcardTemplate() {
71+
conf.set(getTemplateKey("root.*", "capacity"), "6w");
72+
conf.set(getTemplateKey("root.*.*", "capacity"), "5w");
73+
74+
new AutoCreatedQueueTemplate(conf, TEST_QUEUE_A)
75+
.setTemplateEntriesForChild(conf, TEST_QUEUE_AB.getFullPath());
76+
new AutoCreatedQueueTemplate(conf, TEST_QUEUE_AB)
77+
.setTemplateEntriesForChild(conf, TEST_QUEUE_ABC.getFullPath());
78+
79+
Assert.assertEquals("weight is not set", 6f,
80+
conf.getNonLabeledQueueWeight(TEST_QUEUE_AB.getFullPath()), 10e-6);
81+
Assert.assertEquals("weight is not set", 5f,
82+
conf.getNonLabeledQueueWeight(TEST_QUEUE_ABC.getFullPath()), 10e-6);
83+
}
84+
6985
@Test
7086
public void testIgnoredWhenRootWildcarded() {
7187
conf.set(getTemplateKey("*", "capacity"), "6w");

0 commit comments

Comments
 (0)