YARN-2012. Fair Scheduler: allow default queue placement rule to take an arbitrary queue (Ashwin Shankar via Sandy Ryza)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1597204 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sanford Ryza 2014-05-23 22:38:52 +00:00
parent 892ada8fb3
commit 6c56612af5
4 changed files with 62 additions and 6 deletions

View File

@ -99,6 +99,9 @@ Release 2.5.0 - UNRELEASED
YARN-1937. Added owner-only ACLs support for Timeline Client and server.
(Zhijie Shen via vinodkv)
YARN-2012. Fair Scheduler: allow default queue placement rule to take an
arbitrary queue (Ashwin Shankar via Sandy Ryza)
OPTIMIZATIONS
BUG FIXES

View File

@ -276,21 +276,38 @@ public boolean isTerminal() {
}
/**
* Places all apps in the default queue
* Places apps in the specified default queue. If no default queue is
* specified the app is placed in root.default queue.
*/
public static class Default extends QueuePlacementRule {
private String defaultQueueName;
@Override
public void initializeFromXml(Element el)
throws AllocationConfigurationException {
defaultQueueName = el.getAttribute("queue");
if (defaultQueueName != null && !defaultQueueName.isEmpty()) {
if (!defaultQueueName.startsWith("root.")) {
defaultQueueName = "root." + defaultQueueName;
}
} else {
defaultQueueName = "root." + YarnConfiguration.DEFAULT_QUEUE_NAME;
}
super.initializeFromXml(el);
}
@Override
protected String getQueueForApp(String requestedQueue, String user,
Groups groups, Map<FSQueueType, Set<String>> configuredQueues) {
return "root." + YarnConfiguration.DEFAULT_QUEUE_NAME;
return defaultQueueName;
}
@Override
public boolean isTerminal() {
return true;
}
}
/**
* Rejects all apps
*/

View File

@ -133,6 +133,22 @@ public void testTerminals() throws Exception {
parse(sb.toString());
}
@Test
public void testDefaultRuleWithQueueAttribute() throws Exception {
// This test covers the use case where we would like default rule
// to point to a different queue by default rather than root.default
configuredQueues.get(FSQueueType.LEAF).add("root.someDefaultQueue");
StringBuffer sb = new StringBuffer();
sb.append("<queuePlacementPolicy>");
sb.append(" <rule name='specified' create='false' />");
sb.append(" <rule name='default' queue='root.someDefaultQueue'/>");
sb.append("</queuePlacementPolicy>");
QueuePlacementPolicy policy = parse(sb.toString());
assertEquals("root.someDefaultQueue",
policy.assignAppToQueue("root.default", "user1"));
}
@Test
public void testNestedUserQueueParsingErrors() {
// No nested rule specified in hierarchical user queue
@ -311,6 +327,25 @@ public void testNestedUserQueueSpecificRule() throws Exception {
policy.assignAppToQueue("root.parent2", "user2"));
}
@Test
public void testNestedUserQueueDefaultRule() throws Exception {
// This test covers the use case where we would like user queues to be
// created under a default parent queue
configuredQueues.get(FSQueueType.PARENT).add("root.parentq");
StringBuffer sb = new StringBuffer();
sb.append("<queuePlacementPolicy>");
sb.append(" <rule name='specified' create='false' />");
sb.append(" <rule name='nestedUserQueue'>");
sb.append(" <rule name='default' queue='root.parentq'/>");
sb.append(" </rule>");
sb.append(" <rule name='default' />");
sb.append("</queuePlacementPolicy>");
QueuePlacementPolicy policy = parse(sb.toString());
assertEquals("root.parentq.user1",
policy.assignAppToQueue("root.default", "user1"));
}
private QueuePlacementPolicy parse(String str) throws Exception {
// Read and parse the allocations file.
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory

View File

@ -310,7 +310,8 @@ Allocation file format
to parent or by configuring at least one leaf under that queue which makes it a parent.
See example allocation for a sample use case.
* default: the app is placed into the queue named "default".
* default: the app is placed into the queue specified in the queue attribute of the
default rule. If queue attribute is not specified, the app is placed into root.default queue.
* reject: the app is rejected.
@ -348,7 +349,7 @@ Allocation file format
<rule name=“nestedUserQueue”>
<rule name=“secondaryGroupExistingQueue” create=“false” />
</rule>
<rule name="default" />
<rule name="default" queue=“sample_queue” />
</queuePlacementPolicy>
</allocations>
---