private static CommandLine parseArgs(String[] args) throws ParseException {
    Options options = new Options();

    // Cluster
    Option o = new Option("c", "cluster", true,
        "cluster for which jobs are processed");
    o.setArgName("cluster");
    o.setRequired(true);
    options.addOption(o);

    // Input
    o = new Option("o", "output", true,
        "output directory in hdfs. This is where the index files are written.");
    o.setArgName("output-path");
    o.setRequired(true);
    options.addOption(o);

    // Input
    o = new Option("i", "input", true,
        "input directory in hdfs. Default is mapred.job.tracker.history.completed.location.");
    o.setArgName("input-path");
    o.setRequired(false);
    options.addOption(o);

    // Batch
    o = new Option("b", "batchSize", true,
        "The number of files to process in one batch. Default "
            + DEFAULT_BATCH_SIZE);
    o.setArgName("batch-size");
    o.setRequired(false);
    options.addOption(o);

    // raw file size limit
    o = new Option("s", "rawFileSize", true,
        "The max size of file that can be loaded into raw table. Default "
            + DEFAULT_RAW_FILE_SIZE_LIMIT);
    o.setArgName("rawfile-size");
    o.setRequired(false);
    options.addOption(o);

    // Force
    o = new Option("f", "forceAllFiles", false,
        "Force all files in a directory to be processed, no matter the previous processingRecord. Default: false. Usefull for batch loads.");
    o.setRequired(false);
    options.addOption(o);

    // Debugging
    options.addOption("d", "debug", false, "switch on DEBUG log level");

    CommandLineParser parser = new PosixParser();
    CommandLine commandLine = null;
    try {
      commandLine = parser.parse(options, args);
    } catch (Exception e) {
      System.err.println("ERROR: " + e.getMessage() + "\n");
      HelpFormatter formatter = new HelpFormatter();
      formatter.printHelp(NAME + " ", options, true);
      System.exit(-1);
    }

    // Set debug level right away
    if (commandLine.hasOption("d")) {
      Logger log = Logger.getLogger(JobFileRawLoader.class);
      log.setLevel(Level.DEBUG);
    }

    return commandLine;
  }
private static CommandLine parseArgs ( String [ ] args ) throws ParseException { Options options = new Options ( ) ; Option o = new Option ( "c" , "cluster" , true , "cluster for which jobs are processed" ) ; o . setArgName ( "cluster" ) ; o . setRequired ( true ) ; options . addOption ( o ) ; o = new Option ( "o" , "output" , true , "output directory in hdfs. This is where the index files are written." ) ; o . setArgName ( "output-path" ) ; o . setRequired ( true ) ; options . addOption ( o ) ; o = new Option ( "i" , "input" , true , "input directory in hdfs. Default is mapred.job.tracker.history.completed.location." ) ; o . setArgName ( "input-path" ) ; o . setRequired ( false ) ; options . addOption ( o ) ; o = new Option ( "b" , "batchSize" , true , "The number of files to process in one batch. Default " + DEFAULT_BATCH_SIZE ) ; o . setArgName ( "batch-size" ) ; o . setRequired ( false ) ; options . addOption ( o ) ; o = new Option ( "s" , "rawFileSize" , true , "The max size of file that can be loaded into raw table. Default " + DEFAULT_RAW_FILE_SIZE_LIMIT ) ; o . setArgName ( "rawfile-size" ) ; o . setRequired ( false ) ; options . addOption ( o ) ; o = new Option ( "f" , "forceAllFiles" , false , "Force all files in a directory to be processed, no matter the previous processingRecord. Default: false. Usefull for batch loads." ) ; o . setRequired ( false ) ; options . addOption ( o ) ; options . addOption ( "d" , "debug" , false , "switch on DEBUG log level" ) ; CommandLineParser parser = new PosixParser ( ) ; CommandLine commandLine = null ; try { commandLine = parser . parse ( options , args ) ; } catch ( Exception e ) { System . err . println ( "ERROR: " + e . getMessage ( ) + "\n" ) ; HelpFormatter formatter = new HelpFormatter ( ) ; formatter . printHelp ( NAME + " " , options , true ) ; System . exit ( - 1 ) ; } if ( commandLine . hasOption ( "d" ) ) { Logger log = Logger . getLogger ( JobFileRawLoader . class ) ; log . setLevel ( Level . DEBUG ) ; } return commandLine ; }
Parse command-line arguments.

@param args command line arguments passed to program.
@return parsed command line.
@throws ParseException