public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); // Parse generic options String[] genericCmdLineOpts = new GenericOptionsParser(conf, args).getCommandLine().getArgs(); Properties jobProperties = CliOptions.parseArgs(CliMRJobLauncher.class, genericCmdLineOpts); // Launch and run the job System.exit(ToolRunner.run(new CliMRJobLauncher(conf, jobProperties), args)); } }
/** * Returns {@link ParameterTool} for the arguments parsed by {@link GenericOptionsParser}. * * @param args Input array arguments. It should be parsable by {@link GenericOptionsParser} * @return A {@link ParameterTool} * @throws IOException If arguments cannot be parsed by {@link GenericOptionsParser} * @see GenericOptionsParser */ public static ParameterTool paramsFromGenericOptionsParser(String[] args) throws IOException { Option[] options = new GenericOptionsParser(args).getCommandLine().getOptions(); Map<String, String> map = new HashMap<String, String>(); for (Option option : options) { String[] split = option.getValue().split("="); map.put(split[0], split[1]); } return ParameterTool.fromMap(map); } }
E_PARSE_FAILED + " %s", argString); CommandLine line = parser.getCommandLine(); List<String> remainingArgs = Arrays.asList(parser.getRemainingArgs()); LOG.debug("Remaining arguments {}", remainingArgs);
args = new GenericOptionsParser(conf, args).getCommandLine().getArgs();
CommandLine cmd = parser.getCommandLine();
/** * Test that multiple conf arguments can be used. */ public void testConfWithMultipleOpts() throws Exception { String[] args = new String[2]; args[0] = "--conf=foo"; args[1] = "--conf=bar"; GenericOptionsParser g = new GenericOptionsParser(args); assertEquals("1st conf param is incorrect", "foo", g.getCommandLine().getOptionValues("conf")[0]); assertEquals("2st conf param is incorrect", "bar", g.getCommandLine().getOptionValues("conf")[1]); }
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); // Parse generic options String[] genericCmdLineOpts = new GenericOptionsParser(conf, args).getCommandLine().getArgs(); Properties jobProperties = CliOptions.parseArgs(CliMRJobLauncher.class, genericCmdLineOpts); // Launch and run the job System.exit(ToolRunner.run(new CliMRJobLauncher(conf, jobProperties), args)); } }
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); // Parse generic options String[] genericCmdLineOpts = new GenericOptionsParser(conf, args).getCommandLine().getArgs(); Properties jobProperties = CliOptions.parseArgs(CliMRJobLauncher.class, genericCmdLineOpts); // Launch and run the job System.exit(ToolRunner.run(new CliMRJobLauncher(conf, jobProperties), args)); } }
/** * Test that options passed to the constructor are used. */ @SuppressWarnings("static-access") public void testCreateWithOptions() throws Exception { // Create new option newOpt Option opt = OptionBuilder.withArgName("int") .hasArg() .withDescription("A new option") .create("newOpt"); Options opts = new Options(); opts.addOption(opt); // Check newOpt is actually used to parse the args String[] args = new String[2]; args[0] = "--newOpt"; args[1] = "7"; GenericOptionsParser g = new GenericOptionsParser(opts, args); assertEquals("New option was ignored", "7", g.getCommandLine().getOptionValues("newOpt")[0]); }
@Override public final int run(String[] args) throws Exception { Configuration conf = getConf(); GenericOptionsParser optionParser = new GenericOptionsParser(conf, getExtraOptions(), args); String[] otherArgs = optionParser.getRemainingArgs(); if (optionParser.getCommandLine().hasOption(LOCAL_MODE)) { isLocalMode = true; } if (optionParser.getCommandLine().hasOption(DISABLE_SPLIT_GROUPING)) { disableSplitGrouping = true; } if (optionParser.getCommandLine().hasOption(COUNTER_LOG)) { isCountersLog = true; } if (optionParser.getCommandLine().hasOption(GENERATE_SPLIT_IN_CLIENT)) { generateSplitInClient = true; } hadoopShim = new HadoopShimsLoader(conf).getHadoopShim(); return _execute(otherArgs, null, null); }
hadoopShim = new HadoopShimsLoader(conf).getHadoopShim(); GenericOptionsParser optionParser = new GenericOptionsParser(conf, getExtraOptions(), args); if (optionParser.getCommandLine().hasOption(LOCAL_MODE)) { isLocalMode = true; if (tezClient != null) { if (optionParser.getCommandLine().hasOption(DISABLE_SPLIT_GROUPING)) { disableSplitGrouping = true; if (optionParser.getCommandLine().hasOption(COUNTER_LOG)) { isCountersLog = true; if (optionParser.getCommandLine().hasOption(GENERATE_SPLIT_IN_CLIENT)) { generateSplitInClient = true;
/** * Returns {@link ParameterTool} for the arguments parsed by {@link GenericOptionsParser}. * * @param args Input array arguments. It should be parsable by {@link GenericOptionsParser} * @return A {@link ParameterTool} * @throws IOException If arguments cannot be parsed by {@link GenericOptionsParser} * @see GenericOptionsParser */ public static ParameterTool paramsFromGenericOptionsParser(String[] args) throws IOException { Option[] options = new GenericOptionsParser(args).getCommandLine().getOptions(); Map<String, String> map = new HashMap<String, String>(); for (Option option : options) { String[] split = option.getValue().split("="); map.put(split[0], split[1]); } return ParameterTool.fromMap(map); } }
/** * Returns {@link ParameterTool} for the arguments parsed by {@link GenericOptionsParser}. * * @param args Input array arguments. It should be parsable by {@link GenericOptionsParser} * @return A {@link ParameterTool} * @throws IOException If arguments cannot be parsed by {@link GenericOptionsParser} * @see GenericOptionsParser */ public static ParameterTool paramsFromGenericOptionsParser(String[] args) throws IOException { Option[] options = new GenericOptionsParser(args).getCommandLine().getOptions(); Map<String, String> map = new HashMap<String, String>(); for (Option option : options) { String[] split = option.getValue().split("="); map.put(split[0], split[1]); } return ParameterTool.fromMap(map); } }
/** * Returns {@link ParameterTool} for the arguments parsed by {@link GenericOptionsParser}. * * @param args Input array arguments. It should be parsable by {@link GenericOptionsParser} * @return A {@link ParameterTool} * @throws IOException If arguments cannot be parsed by {@link GenericOptionsParser} * @see GenericOptionsParser */ public static ParameterTool paramsFromGenericOptionsParser(String[] args) throws IOException { Option[] options = new GenericOptionsParser(args).getCommandLine().getOptions(); Map<String, String> map = new HashMap<String, String>(); for (Option option : options) { String[] split = option.getValue().split("="); map.put(split[0], split[1]); } return ParameterTool.fromMap(map); } }
/** * Test that multiple conf arguments can be used. */ public void testConfWithMultipleOpts() throws Exception { String[] args = new String[2]; args[0] = "--conf=foo"; args[1] = "--conf=bar"; GenericOptionsParser g = new GenericOptionsParser(args); assertEquals("1st conf param is incorrect", "foo", g.getCommandLine().getOptionValues("conf")[0]); assertEquals("2st conf param is incorrect", "bar", g.getCommandLine().getOptionValues("conf")[1]); }
/** * Test that multiple conf arguments can be used. */ public void testConfWithMultipleOpts() throws Exception { String[] args = new String[2]; args[0] = "--conf=foo"; args[1] = "--conf=bar"; GenericOptionsParser g = new GenericOptionsParser(args); assertEquals("1st conf param is incorrect", "foo", g.getCommandLine().getOptionValues("conf")[0]); assertEquals("2st conf param is incorrect", "bar", g.getCommandLine().getOptionValues("conf")[1]); }
args = new GenericOptionsParser(conf, args).getCommandLine().getArgs();
args = new GenericOptionsParser(conf, args).getCommandLine().getArgs();
/** * Test that options passed to the constructor are used. */ @SuppressWarnings("static-access") public void testCreateWithOptions() throws Exception { // Create new option newOpt Option opt = OptionBuilder.withArgName("int") .hasArg() .withDescription("A new option") .create("newOpt"); Options opts = new Options(); opts.addOption(opt); // Check newOpt is actually used to parse the args String[] args = new String[2]; args[0] = "--newOpt"; args[1] = "7"; GenericOptionsParser g = new GenericOptionsParser(opts, args); assertEquals("New option was ignored", "7", g.getCommandLine().getOptionValues("newOpt")[0]); }
/** * Test that options passed to the constructor are used. */ @SuppressWarnings("static-access") public void testCreateWithOptions() throws Exception { // Create new option newOpt Option opt = OptionBuilder.withArgName("int") .hasArg() .withDescription("A new option") .create("newOpt"); Options opts = new Options(); opts.addOption(opt); // Check newOpt is actually used to parse the args String[] args = new String[2]; args[0] = "--newOpt"; args[1] = "7"; GenericOptionsParser g = new GenericOptionsParser(opts, args); assertEquals("New option was ignored", "7", g.getCommandLine().getOptionValues("newOpt")[0]); }