YARN-10454: Add applicationName policy. Contributed by Peter Bacsko

This commit is contained in:
Szilard Nemeth 2020-10-13 10:11:10 +02:00
parent b3786d6c3c
commit 42358169f6
3 changed files with 22 additions and 1 deletions

View File

@ -166,6 +166,11 @@ public class MappingRuleCreator {
getTargetQueue(rule.getParentQueue(),
"%user"), create);
break;
case APPLICATION_NAME:
action = MappingRuleActions.createPlaceToQueueAction(
getTargetQueue(rule.getParentQueue(),
"%application"), create);
break;
case SET_DEFAULT_QUEUE:
String defaultQueue = rule.getValue();
checkArgument(defaultQueue != null, "default queue is undefined");

View File

@ -40,6 +40,7 @@
"secondaryGroup",
"primaryGroupUser",
"secondaryGroupUser",
"applicationName",
"setDefaultQueue",
"custom" ] },
"parentQueue": { "type": "string" },

View File

@ -43,7 +43,7 @@ public class TestMappingRuleCreator {
private static final String DEFAULT_QUEUE = "root.default";
private static final String SECONDARY_GROUP = "users";
private static final String PRIMARY_GROUP = "superuser";
private static final String APPLICATION_NAME = "MapReduce";
private static final String APPLICATION_NAME = "testapplication";
private static final String SPECIFIED_QUEUE = "root.users.hadoop";
private static final String USER_NAME = "testuser";
@ -316,6 +316,21 @@ public class TestMappingRuleCreator {
verifyPlacementSucceeds("root.users.testuser");
}
@Test
public void testApplicationNamePlacement() {
rule.setPolicy(Policy.APPLICATION_NAME);
verifyPlacementSucceeds(APPLICATION_NAME);
}
@Test
public void testApplicationNamePlacementWithParent() {
rule.setPolicy(Policy.APPLICATION_NAME);
rule.setParentQueue("root.applications");
verifyPlacementSucceeds("root.applications." + APPLICATION_NAME);
}
@Test
public void testDefaultQueueFallback() {
rule.setFallbackResult(FallbackResult.PLACE_DEFAULT);