YARN-10104. FS-CS converter: dry run should work without output defined. Contributed by Peter Bacsko
This commit is contained in:
parent
ca29768035
commit
94f060242e
|
@ -183,13 +183,14 @@ public class FSConfigToCSConfigArgumentHandler {
|
|||
|
||||
private FSConfigToCSConfigConverter prepareAndGetConverter(
|
||||
CommandLine cliParser) {
|
||||
conversionOptions.setDryRun(
|
||||
cliParser.hasOption(CliOption.DRY_RUN.shortSwitch));
|
||||
boolean dryRun =
|
||||
cliParser.hasOption(CliOption.DRY_RUN.shortSwitch);
|
||||
conversionOptions.setDryRun(dryRun);
|
||||
conversionOptions.setNoTerminalRuleCheck(
|
||||
cliParser.hasOption(CliOption.NO_TERMINAL_RULE_CHECK.shortSwitch));
|
||||
|
||||
checkOptionPresent(cliParser, CliOption.YARN_SITE);
|
||||
checkOutputDefined(cliParser);
|
||||
checkOutputDefined(cliParser, dryRun);
|
||||
|
||||
converterParams = validateInputFiles(cliParser);
|
||||
ruleHandler = new FSConfigToCSConfigRuleHandler(conversionOptions);
|
||||
|
@ -238,14 +239,15 @@ public class FSConfigToCSConfigArgumentHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private static void checkOutputDefined(CommandLine cliParser) {
|
||||
private static void checkOutputDefined(CommandLine cliParser,
|
||||
boolean dryRun) {
|
||||
boolean hasOutputDir =
|
||||
cliParser.hasOption(CliOption.OUTPUT_DIR.shortSwitch);
|
||||
|
||||
boolean console =
|
||||
cliParser.hasOption(CliOption.CONSOLE_MODE.shortSwitch);
|
||||
|
||||
if (!console && !hasOutputDir) {
|
||||
if (!console && !hasOutputDir && !dryRun) {
|
||||
throw new PreconditionException(
|
||||
"Output directory or console mode was not defined. Please" +
|
||||
" use -h or --help to see command line switches");
|
||||
|
|
|
@ -108,12 +108,23 @@ public class TestFSConfigToCSConfigArgumentHandler {
|
|||
"-o", FSConfigConverterTestCommons.OUTPUT_DIR);
|
||||
}
|
||||
|
||||
private static List<String> getDefaultArgumentsWithNoOutput() {
|
||||
return Lists.newArrayList("-y", FSConfigConverterTestCommons.YARN_SITE_XML);
|
||||
}
|
||||
|
||||
private String[] getArgumentsAsArrayWithDefaults(String... args) {
|
||||
List<String> result = getDefaultArguments();
|
||||
result.addAll(Arrays.asList(args));
|
||||
return result.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private String[] getArgumentsAsArrayWithDefaultsNoOutput(
|
||||
String... args) {
|
||||
List<String> result = getDefaultArgumentsWithNoOutput();
|
||||
result.addAll(Arrays.asList(args));
|
||||
return result.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private String[] getArgumentsAsArray(String... args) {
|
||||
List<String> result = Lists.newArrayList();
|
||||
result.addAll(Arrays.asList(args));
|
||||
|
@ -426,9 +437,9 @@ public class TestFSConfigToCSConfigArgumentHandler {
|
|||
String expectedErrorMessage) throws Exception {
|
||||
setupFSConfigConversionFiles(true);
|
||||
|
||||
String[] args = getArgumentsAsArrayWithDefaults("-f",
|
||||
String[] args = getArgumentsAsArrayWithDefaultsNoOutput("-f",
|
||||
FSConfigConverterTestCommons.FS_ALLOC_FILE,
|
||||
"-r", FSConfigConverterTestCommons.CONVERSION_RULES_FILE, "-p",
|
||||
"-r", FSConfigConverterTestCommons.CONVERSION_RULES_FILE,
|
||||
"-d");
|
||||
FSConfigToCSConfigArgumentHandler argumentHandler =
|
||||
new FSConfigToCSConfigArgumentHandler(conversionOptions);
|
||||
|
|
Loading…
Reference in New Issue