List of usage examples for org.apache.commons.cli OptionBuilder withArgName
public static OptionBuilder withArgName(String name)
From source file:com.gtwm.jasperexecute.RunJasperReports.java
public static void main(String[] args) throws Exception { RunJasperReports runJasperReports = new RunJasperReports(); // Set up command line parser Options options = new Options(); Option reports = OptionBuilder.withArgName("reportlist").hasArg() .withDescription("Comma separated list of JasperReport XML input files").create("reports"); options.addOption(reports);//from w ww. j a va 2 s. co m Option emailTo = OptionBuilder.withArgName("emailaddress").hasArg() .withDescription("Email address to send generated reports to").create("emailto"); options.addOption(emailTo); Option emailFrom = OptionBuilder.withArgName("emailaddress").hasArg() .withDescription("Sender email address").create("emailfrom"); options.addOption(emailFrom); Option emailSubjectLine = OptionBuilder.withArgName("emailsubject").hasArg() .withDescription("Subject line of email").create("emailsubject"); options.addOption(emailSubjectLine); Option emailHostOption = OptionBuilder.withArgName("emailhost").hasArg() .withDescription("Address of email server").create("emailhost"); options.addOption(emailHostOption); Option emailUsernameOption = OptionBuilder.withArgName("emailuser").hasArg() .withDescription("Username if email server requires authentication").create("emailuser"); options.addOption(emailUsernameOption); Option emailPasswordOption = OptionBuilder.withArgName("emailpass").hasArg() .withDescription("Password if email server requires authentication").create("emailpass"); options.addOption(emailPasswordOption); Option outputFolder = OptionBuilder.withArgName("foldername").hasArg() .withDescription( "Folder to write generated reports to, with trailing separator (slash or backslash)") .create("folder"); options.addOption(outputFolder); Option dbTypeOption = OptionBuilder.withArgName("databasetype").hasArg() .withDescription("Currently supported types are: " + Arrays.asList(DatabaseType.values())) .create("dbtype"); options.addOption(dbTypeOption); Option dbNameOption = OptionBuilder.withArgName("databasename").hasArg() .withDescription("Name of the database to run reports against").create("dbname"); options.addOption(dbNameOption); Option dbUserOption = OptionBuilder.withArgName("username").hasArg() .withDescription("Username to connect to databasewith").create("dbuser"); options.addOption(dbUserOption); Option dbPassOption = OptionBuilder.withArgName("password").hasArg().withDescription("Database password") .create("dbpass"); options.addOption(dbPassOption); Option outputTypeOption = OptionBuilder.withArgName("outputtype").hasArg() .withDescription("Output type, one of: " + Arrays.asList(OutputType.values())).create("output"); options.addOption(outputTypeOption); Option outputFilenameOption = OptionBuilder.withArgName("outputfilename").hasArg() .withDescription("Output filename (excluding filetype suffix)").create("filename"); options.addOption(outputFilenameOption); Option dbHostOption = OptionBuilder.withArgName("host").hasArg().withDescription("Database host address") .create("dbhost"); options.addOption(dbHostOption); Option paramsOption = OptionBuilder.withArgName("parameters").hasArg().withDescription( "Parameters, e.g. param1=boolean:true,param2=string:ABC,param3=double:134.2,param4=integer:85") .create("params"); options.addOption(paramsOption); // Parse command line CommandLineParser parser = new GnuParser(); CommandLine commandLine = parser.parse(options, args); String reportsDefinitionFileNamesCvs = commandLine.getOptionValue("reports"); if (reportsDefinitionFileNamesCvs == null) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar RunJasperReports.jar", options); System.out.println(); System.out.println("See www.agilebase.co.uk/opensource for further documentation"); System.out.println(); throw new IllegalArgumentException("No reports specified"); } String outputPath = commandLine.getOptionValue("folder"); List<String> reportDefinitionFileNames = Arrays.asList(reportsDefinitionFileNamesCvs.split(",")); List<String> outputFileNames = new ArrayList<String>(); DatabaseType databaseType = DatabaseType.POSTGRESQL; String databaseTypeString = commandLine.getOptionValue("dbtype"); if (databaseTypeString != null) { databaseType = DatabaseType.valueOf(commandLine.getOptionValue("dbtype").toUpperCase()); } String databaseName = commandLine.getOptionValue("dbname"); String databaseUsername = commandLine.getOptionValue("dbuser"); String databasePassword = commandLine.getOptionValue("dbpass"); String databaseHost = commandLine.getOptionValue("dbhost"); if (databaseHost == null) { databaseHost = "localhost"; } OutputType outputType = OutputType.PDF; String outputTypeString = commandLine.getOptionValue("output"); if (outputTypeString != null) { outputType = OutputType.valueOf(outputTypeString.toUpperCase()); } String parametersString = commandLine.getOptionValue("params"); Map parameters = runJasperReports.prepareParameters(parametersString); String outputFilenameSpecified = commandLine.getOptionValue("filename"); if (outputFilenameSpecified == null) { outputFilenameSpecified = ""; } // Iterate over reports, generating output for each for (String reportsDefinitionFileName : reportDefinitionFileNames) { String outputFilename = null; if ((reportDefinitionFileNames.size() == 1) && (!outputFilenameSpecified.equals(""))) { outputFilename = outputFilenameSpecified; } else { outputFilename = outputFilenameSpecified + reportsDefinitionFileName.replaceAll("\\..*$", ""); outputFilename = outputFilename.replaceAll("^.*\\/", ""); outputFilename = outputFilename.replaceAll("^.*\\\\", ""); } outputFilename = outputFilename.replaceAll("\\W", "").toLowerCase() + "." + outputType.toString().toLowerCase(); if (outputPath != null) { if (!outputPath.endsWith("\\") && !outputPath.endsWith("/")) { outputPath += java.io.File.separator; } outputFilename = outputPath + outputFilename; } System.out.println("Going to generate report " + outputFilename); if (outputType.equals(OutputType.PDF)) { runJasperReports.generatePdfReport(reportsDefinitionFileName, outputFilename, databaseType, databaseName, databaseUsername, databasePassword, databaseHost, parameters); } else if (outputType.equals(OutputType.TEXT)) { runJasperReports.generateTextReport(reportsDefinitionFileName, outputFilename, databaseType, databaseName, databaseUsername, databasePassword, databaseHost, parameters); } else if (outputType.equals(OutputType.CSV)) { runJasperReports.generateCSVReport(reportsDefinitionFileName, outputFilename, databaseType, databaseName, databaseUsername, databasePassword, databaseHost, parameters); } else if (outputType.equals(OutputType.XLS)) { // NB: parameters are in a different order for XLS for some reasons runJasperReports.generateJxlsReport(reportsDefinitionFileName, outputFilename, databaseType, databaseHost, databaseName, databaseUsername, databasePassword, parameters); } else { runJasperReports.generateHtmlReport(reportsDefinitionFileName, outputFilename, databaseType, databaseName, databaseUsername, databasePassword, databaseHost, parameters); } outputFileNames.add(outputFilename); } String emailRecipientList = commandLine.getOptionValue("emailto"); if (emailRecipientList != null) { Set<String> emailRecipients = new HashSet<String>(Arrays.asList(emailRecipientList.split(","))); String emailSender = commandLine.getOptionValue("emailfrom"); String emailSubject = commandLine.getOptionValue("emailsubject"); if (emailSubject == null) { emailSubject = "Report attached"; } String emailHost = commandLine.getOptionValue("emailhost"); if (emailHost == null) { emailHost = "localhost"; } String emailUser = commandLine.getOptionValue("emailuser"); String emailPass = commandLine.getOptionValue("emailpass"); System.out.println("Emailing reports to " + emailRecipients); runJasperReports.emailReport(emailHost, emailUser, emailPass, emailRecipients, emailSender, emailSubject, outputFileNames); } else { System.out.println("Email not generated (no recipients specified)"); } }
From source file:com.boundary.sdk.event.EventCLI.java
@SuppressWarnings("static-access") private void addMessageOption() { optionMessage = OptionBuilder.withArgName("message").hasArg() .withDescription("Additional description of the event").withLongOpt("message") .create(OPTION_MESSAGE);//from w w w. jav a2 s. c o m options.addOption(optionMessage); }
From source file:edu.umd.windmemory.BuildInvertedIndexHBase.java
/** * Runs this tool./*from www. ja va2 s . c om*/ */ @SuppressWarnings({ "static-access" }) public int run(String[] args) throws Exception { Options options = new Options(); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT)); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(OUTPUT)); // options.addOption(OptionBuilder.withArgName("num").hasArg() // .withDescription("number of reducers").create(NUM_REDUCERS)); CommandLine cmdline; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); return -1; } if (!cmdline.hasOption(INPUT) || !cmdline.hasOption(OUTPUT)) { System.out.println("args: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); return -1; } String inputPath = cmdline.getOptionValue(INPUT); String outputTable = cmdline.getOptionValue(OUTPUT); // int reduceTasks = cmdline.hasOption(NUM_REDUCERS) ? // Integer.parseInt(cmdline.getOptionValue(NUM_REDUCERS)) : 1; Configuration conf = getConf(); conf.addResource(new Path("/etc/hbase/conf/hbase-site.xml")); Configuration hbaseConfig = HBaseConfiguration.create(conf); HBaseAdmin admin = new HBaseAdmin(hbaseConfig); if (admin.tableExists(outputTable)) { LOG.info(String.format("Table '%s' exists: dropping table and recreating.", outputTable)); LOG.info(String.format("Disabling table '%s'", outputTable)); admin.disableTable(outputTable); LOG.info(String.format("Droppping table '%s'", outputTable)); admin.deleteTable(outputTable); } HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(outputTable)); for (int i = 0; i < FAMILIES.length; i++) { HColumnDescriptor hColumnDesc = new HColumnDescriptor(FAMILIES[i]); tableDesc.addFamily(hColumnDesc); } admin.createTable(tableDesc); LOG.info(String.format("Successfully created table '%s'", outputTable)); admin.close(); LOG.info("Tool name: " + BuildInvertedIndexHBase.class.getSimpleName()); LOG.info(" - input path: " + inputPath); LOG.info(" - output path: " + outputTable); // LOG.info(" - num reducers: " + reduceTasks); Job job = Job.getInstance(getConf()); job.setJobName(BuildInvertedIndexHBase.class.getSimpleName()); job.setJarByClass(BuildInvertedIndexHBase.class); // job.setNumReduceTasks(reduceTasks); FileInputFormat.setInputPaths(job, new Path(inputPath)); // FileOutputFormat.setOutputPath(job, new Path(outputPath)); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(PairOfInts.class); // job.setOutputKeyClass(Text.class); // job.setOutputValueClass(PairOfWritables.class); // job.setOutputFormatClass(MapFileOutputFormat.class); job.setMapperClass(MyMapper.class); // job.setReducerClass(MyReducer.class); // Delete the output directory if it exists already. // Path outputDir = new Path(outputPath); // FileSystem.get(getConf()).delete(outputDir, true); TableMapReduceUtil.initTableReducerJob(outputTable, MyTableReducer.class, job); long startTime = System.currentTimeMillis(); job.waitForCompletion(true); System.out.println("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds"); return 0; }
From source file:com.controlj.experiment.bulktrend.trendclient.Main.java
private static Options setupCLOptions() { Options options = new Options(); options.addOption(OptionBuilder.withArgName("directory").hasArg() .withDescription("Directory for trendclient.properties and trendclient.sources").create(PARAM_DIR)); options.addOption(OptionBuilder.withArgName("startDate").hasArg() .withDescription("Starting date to retrieve trends (mm/dd/yyyy). " + "Defaults to yesterday.") .create(PARAM_START));/*from w w w .ja va 2 s .c o m*/ options.addOption(OptionBuilder.withArgName("endDate").hasArg() .withDescription("Ending date to retrieve trends (mm/dd/yyyy). " + "Defaults to yesterday.") .create(PARAM_END)); options.addOption(OptionBuilder.create("help")); options.addOption(OptionBuilder.withDescription("Disable zip compression").create(PARAM_NOZIP)); options.addOption(OptionBuilder.withArgName("file").hasOptionalArg() .withDescription("Read data from file instead of over HTTP").create(PARAM_TESTFILE)); return options; }
From source file:edu.umd.honghongie.BooleanRetrievalHBase.java
/** * Runs this tool.//ww w . j ava 2 s. c om */ @SuppressWarnings({ "static-access" }) public int run(String[] args) throws Exception { Options options = new Options(); options.addOption( OptionBuilder.withArgName("table").hasArg().withDescription("HBase table name").create(TABLE)); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(COLLECTION)); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(TABLE) || !cmdline.hasOption(COLLECTION)) { System.out.println("args: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); System.exit(-1); } String tableName = cmdline.getOptionValue(TABLE); String collectionPath = cmdline.getOptionValue(COLLECTION); if (collectionPath.endsWith(".gz")) { System.out.println("gzipped collection is not seekable: use compressed version!"); System.exit(-1); } FileSystem fs = FileSystem.get(new Configuration()); initialize(tableName, collectionPath, fs); String[] queries = { "outrageous fortune AND", "white rose AND", "means deceit AND", "white red OR rose AND pluck AND", "unhappy outrageous OR good your AND OR fortune AND" }; for (String q : queries) { System.out.println("Query: " + q); runQuery(q); System.out.println(""); } return 1; }
From source file:info.fetter.logstashforwarder.Forwarder.java
@SuppressWarnings("static-access") static void parseOptions(String[] args) { Options options = new Options(); Option helpOption = new Option("help", "print this message"); Option quietOption = new Option("quiet", "operate in quiet mode - only emit errors to log"); Option debugOption = new Option("debug", "operate in debug mode"); Option debugWatcherOption = new Option("debugwatcher", "operate watcher in debug mode"); Option traceOption = new Option("trace", "operate in trace mode"); Option tailOption = new Option("tail", "read new files from the end"); Option spoolSizeOption = OptionBuilder.withArgName("number of events").hasArg() .withDescription("event count spool threshold - forces network flush").create("spoolsize"); Option idleTimeoutOption = OptionBuilder.withArgName("").hasArg() .withDescription("time between file reads in seconds").create("idletimeout"); Option configOption = OptionBuilder.withArgName("config file").hasArg().isRequired() .withDescription("path to logstash-forwarder configuration file").create("config"); Option signatureLengthOption = OptionBuilder.withArgName("signature length").hasArg() .withDescription("Maximum length of file signature").create("signaturelength"); Option logfileOption = OptionBuilder.withArgName("logfile name").hasArg().withDescription("Logfile name") .create("logfile"); Option logfileSizeOption = OptionBuilder.withArgName("logfile size").hasArg() .withDescription("Logfile size (default 10M)").create("logfilesize"); Option logfileNumberOption = OptionBuilder.withArgName("number of logfiles").hasArg() .withDescription("Number of logfiles (default 5)").create("logfilenumber"); Option sincedbOption = OptionBuilder.withArgName("sincedb file").hasArg() .withDescription("Sincedb file name").create("sincedb"); options.addOption(helpOption).addOption(idleTimeoutOption).addOption(spoolSizeOption).addOption(quietOption) .addOption(debugOption).addOption(debugWatcherOption).addOption(traceOption).addOption(tailOption) .addOption(signatureLengthOption).addOption(configOption).addOption(logfileOption) .addOption(logfileNumberOption).addOption(logfileSizeOption).addOption(sincedbOption); CommandLineParser parser = new GnuParser(); try {/* ww w . j av a 2s . c o m*/ CommandLine line = parser.parse(options, args); if (line.hasOption("spoolsize")) { spoolSize = Integer.parseInt(line.getOptionValue("spoolsize")); } if (line.hasOption("idletimeout")) { idleTimeout = Integer.parseInt(line.getOptionValue("idletimeout")); } if (line.hasOption("config")) { config = line.getOptionValue("config"); } if (line.hasOption("signaturelength")) { signatureLength = Integer.parseInt(line.getOptionValue("signaturelength")); } if (line.hasOption("quiet")) { logLevel = ERROR; } if (line.hasOption("debug")) { logLevel = DEBUG; } if (line.hasOption("trace")) { logLevel = TRACE; } if (line.hasOption("debugwatcher")) { debugWatcherSelected = true; } if (line.hasOption("tail")) { tailSelected = true; } if (line.hasOption("logfile")) { logfile = line.getOptionValue("logfile"); } if (line.hasOption("logfilesize")) { logfileSize = line.getOptionValue("logfilesize"); } if (line.hasOption("logfilenumber")) { logfileNumber = Integer.parseInt(line.getOptionValue("logfilenumber")); } if (line.hasOption("sincedb")) { sincedbFile = line.getOptionValue("sincedb"); } } catch (ParseException e) { printHelp(options); System.exit(1); ; } catch (NumberFormatException e) { System.err.println("Value must be an integer"); printHelp(options); System.exit(2); ; } }
From source file:edu.umd.shrawanraina.BooleanRetrievalCompressed.java
/** * Runs this tool.// ww w .j a va 2 s.co m */ @SuppressWarnings({ "static-access" }) public int run(String[] args) throws Exception { Options options = new Options(); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INDEX)); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(COLLECTION)); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(INDEX) || !cmdline.hasOption(COLLECTION)) { System.out.println("args: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(LookupPostings.class.getName(), options); ToolRunner.printGenericCommandUsage(System.out); System.exit(-1); } String indexPath = cmdline.getOptionValue(INDEX); String collectionPath = cmdline.getOptionValue(COLLECTION); if (collectionPath.endsWith(".gz")) { System.out.println("gzipped collection is not seekable: use compressed version!"); System.exit(-1); } FileSystem fs = FileSystem.get(new Configuration()); initialize(indexPath, collectionPath, fs); String[] queries = { "outrageous fortune AND", "white rose AND", "means deceit AND", "white red OR rose AND pluck AND", "unhappy outrageous OR good your AND OR fortune AND" }; for (String q : queries) { System.out.println("Query: " + q); runQuery(q); System.out.println(""); } return 1; }
From source file:com.github.errantlinguist.latticevisualiser.ArgParser.java
/** * Creates and adds a state size multiplier option to a given * {@link Options} object.//www. ja v a 2 s. co m * * @param options * The <code>Options</code> object to add to. */ private static void addStateSizeMultiplierOption(final Options options) { OptionBuilder.withLongOpt(STATE_SIZE_MULTIPLIER_KEY_LONG); OptionBuilder.withDescription(STATE_SIZE_MULTIPLIER_DESCR); OptionBuilder.hasArg(); OptionBuilder.withArgName(SIZE_ARG_NAME); OptionBuilder.withType(double.class); final Option stateSizeMultiplier = OptionBuilder.create(STATE_SIZE_MULTIPLIER_KEY); options.addOption(stateSizeMultiplier); }
From source file:edu.umd.gorden2.BuildInvertedIndex.java
/** * Runs this tool.//from ww w . j a v a2 s .c o m */ @SuppressWarnings({ "static-access" }) public int run(String[] args) throws Exception { Options options = new Options(); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT)); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(OUTPUT)); options.addOption(OptionBuilder.withArgName("num").hasArg().withDescription("number of reducers") .create(NUM_REDUCERS)); CommandLine cmdline; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); return -1; } if (!cmdline.hasOption(INPUT) || !cmdline.hasOption(OUTPUT)) { System.out.println("args: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); return -1; } String inputPath = cmdline.getOptionValue(INPUT); String outputPath = cmdline.getOptionValue(OUTPUT); int reduceTasks = cmdline.hasOption(NUM_REDUCERS) ? Integer.parseInt(cmdline.getOptionValue(NUM_REDUCERS)) : 1; LOG.info("Tool name: " + BuildInvertedIndex.class.getSimpleName()); LOG.info(" - input path: " + inputPath); LOG.info(" - output path: " + outputPath); LOG.info(" - num reducers: " + reduceTasks); Job job = Job.getInstance(getConf()); job.setJobName(BuildInvertedIndex.class.getSimpleName()); job.setJarByClass(BuildInvertedIndex.class); job.setNumReduceTasks(reduceTasks); FileInputFormat.setInputPaths(job, new Path(inputPath)); FileOutputFormat.setOutputPath(job, new Path(outputPath)); job.setMapOutputKeyClass(PairOfStringInt.class); job.setMapOutputValueClass(IntWritable.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(PairOfWritables.class); //job.setOutputFormatClass(MapFileOutputFormat.class); job.setMapperClass(MyMapper.class); job.setReducerClass(MyReducer.class); job.setPartitionerClass(MyPartitioner.class); // Delete the output directory if it exists already. Path outputDir = new Path(outputPath); FileSystem.get(getConf()).delete(outputDir, true); long startTime = System.currentTimeMillis(); job.waitForCompletion(true); System.out.println("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds"); return 0; }
From source file:io.bfscan.clueweb12.DumpWarcRecordsToTermIds.java
/** * Runs this tool./*from w w w . j av a 2 s . c om*/ */ @SuppressWarnings("static-access") public int run(String[] args) throws Exception { Options options = new Options(); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT_OPTION)); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(OUTPUT_OPTION)); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("dictionary").create(DICTIONARY_OPTION)); options.addOption(OptionBuilder.withArgName("num").hasArg().withDescription("number of reducers") .create(REDUCERS_OPTION)); CommandLine cmdline; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); System.err.println("Error parsing command line: " + exp.getMessage()); return -1; } if (!cmdline.hasOption(INPUT_OPTION) || !cmdline.hasOption(OUTPUT_OPTION) || !cmdline.hasOption(DICTIONARY_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); return -1; } String input = cmdline.getOptionValue(INPUT_OPTION); String output = cmdline.getOptionValue(OUTPUT_OPTION); String dictionary = cmdline.getOptionValue(DICTIONARY_OPTION); Job job = new Job(getConf(), DumpWarcRecordsToTermIds.class.getSimpleName() + ":" + input); job.setJarByClass(DumpWarcRecordsToTermIds.class); LOG.info("Tool name: " + DumpWarcRecordsToTermIds.class.getSimpleName()); LOG.info(" - input: " + input); LOG.info(" - output: " + output); LOG.info(" - dictionary: " + dictionary); if (cmdline.hasOption(REDUCERS_OPTION)) { int numReducers = Integer.parseInt(cmdline.getOptionValue(REDUCERS_OPTION)); LOG.info(" - reducers: " + numReducers); job.setNumReduceTasks(numReducers); } else { job.setNumReduceTasks(0); } FileInputFormat.setInputPaths(job, input); FileOutputFormat.setOutputPath(job, new Path(output)); job.getConfiguration().set(DICTIONARY_OPTION, dictionary); job.setInputFormatClass(ClueWeb12InputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(Text.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); job.setMapperClass(MyMapper.class); FileSystem.get(getConf()).delete(new Path(output), true); long startTime = System.currentTimeMillis(); job.waitForCompletion(true); LOG.info("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds"); return 0; }