public static CmdLineParser parseArgs(String[] args, Object t) { CmdLineParser parser = new CmdLineParser(t); try { parser.parseArgument(args); } catch (CmdLineException e) { e.printStackTrace(); System.err.println(e.getMessage()); parser.printUsage(System.err); System.err.println(); System.exit(1); } return parser; }
private static ServerConfiguration parseConfiguration(String[] args) throws CmdLineException { ServerConfiguration configuration = new ServerConfiguration(); CmdLineParser parser = new CmdLineParser(configuration); try { parser.parseArgument(args); } catch (CmdLineException e) { e.printStackTrace(System.err); printUsage(parser); throw e; } return configuration; }
/** * prepare the tool for running */ public void prepare() { final CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(this.args); this.validate(); } catch (final CmdLineException e) { e.printStackTrace(); System.err.println(e.getMessage()); System.err.println("Usage: java -jar PicSlurper.jar [options...] "); parser.printUsage(System.err); System.err.println(this.getExtractUsageInfo()); System.exit(1); } }
public static void main(String[] args) throws Exception { // force utf-8 System.setProperty("file.encoding", "UTF-8"); Charset.defaultCharset(); CLI cli = new CLI(); CmdLineParser cmd = new CmdLineParser(cli); try { cmd.parseArgument(args); } catch (CmdLineException e) { System.out.print("Usage: java -jar provisio-jenkins-uber-<v>.jar"); cmd.printSingleLineUsage(System.out); System.out.println(); e.printStackTrace(); return; } cli.doMain(); }
public static void main(String... args) { MigrateEmailFrequencyData element = new MigrateEmailFrequencyData(); CmdLineParser parser = new CmdLineParser(element); try { parser.parseArgument(args); //If it is null or too big if(element.batchSize == null || element.batchSize > 1000000) { element.batchSize = 50000; } } catch (CmdLineException e) { LOG.error(e.getMessage(), e); e.printStackTrace(); System.exit(1); } element.migrate(); }
public static void main(String... args) { PopulateEmailHash element = new PopulateEmailHash(); CmdLineParser parser = new CmdLineParser(element); try { parser.parseArgument(args); // If it is null or too big if (element.batchSize == null || element.batchSize > 1000000) { element.batchSize = 50000; } } catch (CmdLineException e) { LOG.error(e.getMessage(), e); e.printStackTrace(); System.exit(1); } element.migrate(); }
public static void main(String... args) throws NoSuchAlgorithmException { RecalculateAndFixEmailHash element = new RecalculateAndFixEmailHash(); CmdLineParser parser = new CmdLineParser(element); try { parser.parseArgument(args); if(element.customOffset == null) { element.customOffset = 0; } // If it is null or too big if (element.batchSize == null || element.batchSize > 1000000) { element.batchSize = 50000; } if(element.fixErrors == null) { element.fixErrors = false; } if(element.testMode == null) { element.testMode = false; } } catch (CmdLineException e) { LOG.error(e.getMessage(), e); e.printStackTrace(); System.exit(1); } element.migrate(); }
parser.parseArgument(args); } catch (CmdLineException e) { e.printStackTrace(); System.exit(-1);
parser.parseArgument(args); } catch (CmdLineException e) { e.printStackTrace(); System.exit(-1);
protected synchronized void loadOptions(Reducer<Text, BytesWritable, Text, BytesWritable>.Context context) throws IOException { try { options = new HadoopTwitterTokenToolOptions(context.getConfiguration().getStrings(ARGS_KEY)); options.prepare(); final Path outpath = HadoopToolsUtil.getOutputPath(options); timeIndex = CountTweetsInTimeperiod.readTimeIndex(CountTweetsInTimeperiod.constructIndexPath(outpath)); final Path timecountOut = new Path(outpath, CountTweetsInTimeperiod.TIMECOUNT_DIR); final Path statsout = new Path(timecountOut, CountTweetsInTimeperiod.GLOBAL_STATS_FILE); final FileSystem fs = HadoopToolsUtil.getFileSystem(statsout); final WritableEnumCounter<TextEntryType> et = new WritableEnumCounter<TextEntryType>() { @Override public TextEntryType valueOf(String str) { return TextEntryType.valueOf(str); } }; tgs = IOUtils.read(fs.open(statsout), et); } catch (final CmdLineException e) { e.printStackTrace(); throw new IOException(e); } catch (final Exception e) { e.printStackTrace(); throw new IOException(e); } }
protected synchronized void loadOptions(Reducer<Text, BytesWritable, Text, BytesWritable>.Context context) throws IOException { try { options = new HadoopTwitterTokenToolOptions(context.getConfiguration().getStrings(ARGS_KEY)); options.prepare(); final Path outpath = HadoopToolsUtil.getOutputPath(options); timeIndex = CountTweetsInTimeperiod.readTimeIndex(CountTweetsInTimeperiod.constructIndexPath(outpath)); final Path timecountOut = new Path(outpath, CountTweetsInTimeperiod.TIMECOUNT_DIR); final Path statsout = new Path(timecountOut, CountTweetsInTimeperiod.GLOBAL_STATS_FILE); final FileSystem fs = HadoopToolsUtil.getFileSystem(statsout); final WritableEnumCounter<TextEntryType> et = new WritableEnumCounter<TextEntryType>() { @Override public TextEntryType valueOf(String str) { return TextEntryType.valueOf(str); } }; tgs = IOUtils.read(fs.open(statsout), et); } catch (final CmdLineException e) { e.printStackTrace(); throw new IOException(e); } catch (final Exception e) { e.printStackTrace(); throw new IOException(e); } }