public static ContentMode parseContentMode(OptionSet optionSet) { ContentMode contentMode = ContentMode.all; if (optionSet.hasArgument("content")) { String format = (String) optionSet.valueOf("content"); if (format.equals("jvm")) { contentMode = ContentMode.jvm; } else if (format.equals("thread")) { contentMode = ContentMode.thread; } } return contentMode; }
public static Integer parseInterval(OptionSet optionSet) { Integer interval = OptionAdvanceParser.DEFAULT_INTERVAL; if (optionSet.hasArgument("interval")) { interval = (Integer) (optionSet.valueOf("interval")); if (interval < 1) { throw new IllegalArgumentException("Interval cannot be set below 1.0"); } } return interval; } }
public static OutputFormat parseOutputFormat(OptionSet optionSet) { OutputFormat outputFormat = OutputFormat.console; if (optionSet.hasArgument("output")) { String format = (String) optionSet.valueOf("output"); if (format.equals("clean")) { outputFormat = OutputFormat.cleanConsole; } else if (format.equals("text")) { outputFormat = OutputFormat.text; } } return outputFormat; }
protected boolean fetchBooleanOption(String name, OptionSet options, Properties properties, boolean defaultVal) { if ( options != null && options.has(name) ) { if ( !options.hasArgument(name) ) return true; else return Boolean.valueOf((String) options.valueOf(name)); } else if ( (properties != null) && properties.containsKey(name) ) return Boolean.valueOf(properties.getProperty(name)); else return defaultVal; }
public static ThreadInfoMode parseThreadInfoMode(OptionSet optionSet) { ThreadInfoMode threadInfoMode = ThreadInfoMode.cpu; if (optionSet.hasArgument("mode")) { String mode = (String) optionSet.valueOf("mode"); threadInfoMode = ThreadInfoMode.parse(mode); } return threadInfoMode; }
private static boolean extractBoolOption(OptionSet options, String optionName) { boolean optionValue = false; if(options.has(optionName)) { if(options.hasArgument(optionName)) { optionValue = (Boolean) options.valueOf(optionName); } else { optionValue = true; } } return optionValue; }
protected String commandName(OptionSet optionSet) { Set<String> matches = new HashSet<>(3); getCommandManager().getAllCommands().forEach((name, mc) -> { if (!mc.isHidden() && !mc.isDefault() && optionSet.has(name) && !optionSet.hasArgument(name)) { matches.add(name); } }); switch (matches.size()) { case 0: // default command should be invoked return null; case 1: return matches.iterator().next(); default: String opts = String.join(", ", matches); String message = String.format("CLI options match multiple commands: %s.", opts); throw new BootiqueException(1, message); } }
if (options.hasArgument("help")) { printUsage(); return; if (!options.hasArgument("urls") || !options.hasArgument("partitions") || !options.hasArgument("store") || !options.hasArgument("bad-key-file")) { printUsage(); return; if (options.hasArgument(ComparisonTypeArgument)) { String comparisonArgument = (String) options.valueOf(ComparisonTypeArgument); comparisonArgument = comparisonArgument.toUpperCase();
static CodecFactory codecFactory(OptionSet opts, OptionSpec<String> codec, OptionSpec<Integer> level, String defaultCodec) { String codecName = opts.hasArgument(codec) ? codec.value(opts) : defaultCodec; if(codecName.equals(DEFLATE_CODEC)) { return CodecFactory.deflateCodec(level.value(opts)); } else if(codecName.equals(DataFileConstants.XZ_CODEC)) { return CodecFactory.xzCodec(level.value(opts)); } else { return CodecFactory.fromString(codec.value(opts)); } } }
if(!options.hasArgument("url") || !options.hasArgument("script") || !options.hasArgument("output")) { printUsageAndDie("Missing a required argument."); return;
return; if(!options.hasArgument("url") || !options.hasArgument("stores") || !options.hasArgument("keyfile")) { printUsageAndDie("Missing a required argument."); return; if(options.hasArgument("zone")) { zoneId = ((Integer) options.valueOf("zone")).intValue(); if(options.hasArgument("stores")) { @SuppressWarnings("unchecked") List<String> list = (List<String>) options.valuesOf("stores"); if(options.hasArgument("check-keys-exist")) { checkKeysCount = ((Integer) options.valueOf("check-keys-exist")).intValue(); if(checkKeysCount <= 0) {
if(options.hasArgument("help")) { parser.printHelpOn(System.out); printUsage(); return; if(!options.hasArgument("url") || !options.hasArgument("out-dir")) { parser.printHelpOn(System.out); printUsageAndDie("Missing a required argument."); if(options.hasArgument("store-names")) { @SuppressWarnings("unchecked") List<String> list = (List<String>) options.valuesOf("store-names"); if(options.hasArgument("partition-ids")) { @SuppressWarnings("unchecked") List<Integer> list = (List<Integer>) options.valuesOf("partition-ids"); if(options.hasArgument("parallelism")) { nodeParallelism = (Integer) options.valueOf("parallelism"); if(options.hasArgument("records-per-partition")) { recordsPerPartition = (Integer) options.valueOf("records-per-partition"); if(options.hasArgument("keys-per-second-limit")) { keysPerSecondLimit = (Integer) options.valueOf("keys-per-second-limit"); if(options.hasArgument("progress-period-ops")) { progressPeriodOps = (Integer) options.valueOf("progress-period-ops");
if(!options.hasArgument("id") || !options.hasArgument("path")) { printUsageAndDie("Missing a required argument."); return;
return; if(!options.hasArgument("url") || !options.hasArgument("in-dir") || !options.hasArgument("out-dir")) { parser.printHelpOn(System.out); printUsageAndDie("Missing a required argument."); if(options.hasArgument("store-names")) { @SuppressWarnings("unchecked") List<String> list = (List<String>) options.valuesOf("store-names"); if(options.hasArgument("parallelism")) { keyParallelism = (Integer) options.valueOf("parallelism"); if(options.hasArgument("progress-period-ops")) { progressPeriodOps = (Integer) options.valueOf("progress-period-ops"); if(options.hasArgument("output-batch-size")) { outputBatchSize = (Integer) options.valueOf("output-batch-size");
if (optionSet.hasArgument("jmxurl")) { jmxHostAndPort = (String) optionSet.valueOf("jmxurl"); if (optionSet.hasArgument("width")) { width = (Integer) optionSet.valueOf("width"); if (optionSet.hasArgument("limit")) { Integer limit = (Integer) optionSet.valueOf("limit"); view.threadLimit = limit; if (optionSet.hasArgument("filter")) { String filter = (String) optionSet.valueOf("filter"); view.threadNameFilter = filter; app.updateInterval(interval); if (optionSet.hasArgument("n")) { Integer iterations = (Integer) optionSet.valueOf("n"); app.maxIterations = iterations;
if(options.hasArgument("help")) { parser.printHelpOn(System.out); printUsage(); return; if(!options.hasArgument("url") || !options.hasArgument("node") || !options.hasArgument("newurl")) { parser.printHelpOn(System.out); printUsageAndDie("Missing a required argument.");
if (a.hasArgument("delay")) if (a.hasArgument("n")) if (a.hasArgument("pid")) if (a.hasArgument("width")) if (a.hasArgument("threadlimit")) if (a.hasArgument("threadnamewidth"))
if (options.hasArgument(CliStrings.START_SERVER__CRITICAL__HEAP__PERCENTAGE)) { setCriticalHeapPercentage(Float.parseFloat(ObjectUtils .toString(options.valueOf(CliStrings.START_SERVER__CRITICAL__HEAP__PERCENTAGE)))); if (options.hasArgument(CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE)) { setEvictionHeapPercentage(Float.parseFloat(ObjectUtils .toString(options.valueOf(CliStrings.START_SERVER__EVICTION__HEAP__PERCENTAGE)))); if (options.hasArgument(CliStrings.START_SERVER__CRITICAL_OFF_HEAP_PERCENTAGE)) { setCriticalOffHeapPercentage(Float.parseFloat(ObjectUtils .toString(options.valueOf(CliStrings.START_SERVER__CRITICAL_OFF_HEAP_PERCENTAGE)))); if (options.hasArgument(CliStrings.START_SERVER__EVICTION_OFF_HEAP_PERCENTAGE)) { setEvictionOffHeapPercentage(Float.parseFloat(ObjectUtils .toString(options.valueOf(CliStrings.START_SERVER__EVICTION_OFF_HEAP_PERCENTAGE)))); if (options.hasArgument(CliStrings.START_SERVER__MAX__CONNECTIONS)) { setMaxConnections(Integer.parseInt( ObjectUtils.toString(options.valueOf(CliStrings.START_SERVER__MAX__CONNECTIONS)))); if (options.hasArgument(CliStrings.START_SERVER__MAX__MESSAGE__COUNT)) { setMaxMessageCount(Integer.parseInt( ObjectUtils.toString(options.valueOf(CliStrings.START_SERVER__MAX__MESSAGE__COUNT)))); if (options.hasArgument(CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE)) { setMessageTimeToLive(Integer.parseInt(ObjectUtils .toString(options.valueOf(CliStrings.START_SERVER__MESSAGE__TIME__TO__LIVE)))); if (options.hasArgument(CliStrings.START_SERVER__SOCKET__BUFFER__SIZE)) {
final boolean syslog; if (parsed.hasArgument(syslogOption)) { syslog = parsed.valueOf(syslogOption); } else {
if(optionSet.hasArgument("help")) { try { parser.printHelpOn(System.out); System.exit(0); if(!optionSet.hasArgument("url")) { printUsage("Missing required 'url' argument.", parser); if(!optionSet.hasArgument("store")) { printUsage("Missing required 'store' argument.", parser);