YARN-10157. FS-CS converter: initPropertyActions() is not called without rules file. Contributed by Peter Bacsko

This commit is contained in:
Szilard Nemeth 2020-02-24 21:45:49 +01:00
parent 929004074f
commit 34cf63c7d0
3 changed files with 40 additions and 3 deletions

View File

@ -166,11 +166,13 @@ private Resource getClusterResource(
private void loadConversionRules(String rulesFile) throws IOException {
if (rulesFile != null) {
LOG.info("Reading conversion rules file from: " + rulesFile);
this.ruleHandler.loadRulesFromFile(rulesFile);
ruleHandler.loadRulesFromFile(rulesFile);
} else {
LOG.info("Conversion rules file is not defined, " +
"using default conversion config!");
}
ruleHandler.initPropertyActions();
}
private Configuration getInputYarnSiteConfig(

View File

@ -95,7 +95,6 @@ void loadRulesFromFile(String ruleFile) throws IOException {
properties.load(is);
}
actions = new HashMap<>();
initPropertyActions();
}
public FSConfigToCSConfigRuleHandler(ConversionOptions conversionOptions) {
@ -113,7 +112,7 @@ public FSConfigToCSConfigRuleHandler(ConversionOptions conversionOptions) {
initPropertyActions();
}
private void initPropertyActions() {
public void initPropertyActions() {
setActionForProperty(MAX_CAPACITY_PERCENTAGE);
setActionForProperty(MAX_CHILD_CAPACITY);
setActionForProperty(USER_MAX_RUNNING_APPS);

View File

@ -26,6 +26,7 @@
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.USER_MAX_APPS_DEFAULT;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.USER_MAX_RUNNING_APPS;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.RuleAction.ABORT;
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.converter.FSConfigToCSConfigRuleHandler.RuleAction.WARNING;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@ -372,6 +373,41 @@ public void testConvertFSConfigurationRulesFile() throws Exception {
ABORT, actions.get(QUEUE_AUTO_CREATE));
}
@Test
public void testConvertFSConfigurationWithoutRulesFile() throws Exception {
ruleHandler = new FSConfigToCSConfigRuleHandler(
createDefaultConversionOptions());
createConverter();
FSConfigToCSConfigConverterParams params =
createDefaultParamsBuilder()
.withClusterResource(CLUSTER_RESOURCE_STRING)
.build();
converter.convert(params);
ruleHandler = converter.getRuleHandler();
Map<String, FSConfigToCSConfigRuleHandler.RuleAction> actions =
ruleHandler.getActions();
assertEquals("maxCapacityPercentage",
WARNING, actions.get(MAX_CAPACITY_PERCENTAGE));
assertEquals("maxChildCapacity",
WARNING, actions.get(MAX_CHILD_CAPACITY));
assertEquals("userMaxRunningApps",
WARNING, actions.get(USER_MAX_RUNNING_APPS));
assertEquals("userMaxAppsDefault",
WARNING, actions.get(USER_MAX_APPS_DEFAULT));
assertEquals("dynamicMaxAssign",
WARNING, actions.get(DYNAMIC_MAX_ASSIGN));
assertEquals("specifiedNotFirstRule",
WARNING, actions.get(SPECIFIED_NOT_FIRST));
assertEquals("reservationSystem",
WARNING, actions.get(RESERVATION_SYSTEM));
assertEquals("queueAutoCreate",
WARNING, actions.get(QUEUE_AUTO_CREATE));
}
@Test
public void testConvertFSConfigurationUndefinedYarnSiteConfig()
throws Exception {