YARN-10783. Allow definition of auto queue template properties in root. Contributed by Andras Gyori
This commit is contained in:
parent
1cbcde04f3
commit
2541efa496
|
@ -29,6 +29,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.AUTO_QUEUE_CREATION_V2_PREFIX;
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.AUTO_QUEUE_CREATION_V2_PREFIX;
|
||||||
|
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.ROOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A handler for storing and setting auto created queue template settings.
|
* A handler for storing and setting auto created queue template settings.
|
||||||
|
@ -68,6 +69,10 @@ public class AutoCreatedQueueTemplate {
|
||||||
*/
|
*/
|
||||||
public void setTemplateEntriesForChild(Configuration conf,
|
public void setTemplateEntriesForChild(Configuration conf,
|
||||||
String childQueuePath) {
|
String childQueuePath) {
|
||||||
|
if (childQueuePath.equals(ROOT)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get all properties that are explicitly set
|
// Get all properties that are explicitly set
|
||||||
Set<String> alreadySetProps = conf.getPropsWithPrefix(
|
Set<String> alreadySetProps = conf.getPropsWithPrefix(
|
||||||
CapacitySchedulerConfiguration.getQueuePrefix(childQueuePath)).keySet();
|
CapacitySchedulerConfiguration.getQueuePrefix(childQueuePath)).keySet();
|
||||||
|
@ -94,8 +99,8 @@ public class AutoCreatedQueueTemplate {
|
||||||
List<String> queuePathParts = new ArrayList<>(Arrays.asList(
|
List<String> queuePathParts = new ArrayList<>(Arrays.asList(
|
||||||
queuePath.split("\\.")));
|
queuePath.split("\\.")));
|
||||||
|
|
||||||
if (queuePathParts.size() <= 1) {
|
if (queuePathParts.size() <= 1 && !queuePath.equals(ROOT)) {
|
||||||
// This is either root or an empty queue name
|
// This is an invalid queue path
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int queuePathMaxIndex = queuePathParts.size() - 1;
|
int queuePathMaxIndex = queuePathParts.size() - 1;
|
||||||
|
@ -106,7 +111,10 @@ public class AutoCreatedQueueTemplate {
|
||||||
// MAX_WILDCARD_LEVEL will be configurable in the future
|
// MAX_WILDCARD_LEVEL will be configurable in the future
|
||||||
int supportedWildcardLevel = Math.min(queuePathMaxIndex - 1,
|
int supportedWildcardLevel = Math.min(queuePathMaxIndex - 1,
|
||||||
MAX_WILDCARD_LEVEL);
|
MAX_WILDCARD_LEVEL);
|
||||||
|
// Allow root to have template properties
|
||||||
|
if (queuePath.equals(ROOT)) {
|
||||||
|
supportedWildcardLevel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Collect all template entries
|
// Collect all template entries
|
||||||
while (wildcardLevel <= supportedWildcardLevel) {
|
while (wildcardLevel <= supportedWildcardLevel) {
|
||||||
|
|
|
@ -109,6 +109,17 @@ public class TestAutoCreatedQueueTemplate {
|
||||||
newConf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
|
newConf.getNonLabeledQueueWeight(TEST_QUEUE_ABC), 10e-6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRootTemplate() {
|
||||||
|
conf.set(getTemplateKey("root", "capacity"), "2w");
|
||||||
|
|
||||||
|
AutoCreatedQueueTemplate template =
|
||||||
|
new AutoCreatedQueueTemplate(conf, ROOT);
|
||||||
|
template.setTemplateEntriesForChild(conf, TEST_QUEUE_A);
|
||||||
|
Assert.assertEquals("root property is not set", 2f,
|
||||||
|
conf.getNonLabeledQueueWeight(TEST_QUEUE_A), 10e-6);
|
||||||
|
}
|
||||||
|
|
||||||
private String getTemplateKey(String queuePath, String entryKey) {
|
private String getTemplateKey(String queuePath, String entryKey) {
|
||||||
return CapacitySchedulerConfiguration.getQueuePrefix(queuePath)
|
return CapacitySchedulerConfiguration.getQueuePrefix(queuePath)
|
||||||
+ AutoCreatedQueueTemplate.AUTO_QUEUE_TEMPLATE_PREFIX + entryKey;
|
+ AutoCreatedQueueTemplate.AUTO_QUEUE_TEMPLATE_PREFIX + entryKey;
|
||||||
|
|
Loading…
Reference in New Issue