static OptionSpec<String> compressionCodecOption(OptionParser optParser) { return optParser .accepts("codec", "Compression codec") .withRequiredArg() .ofType(String.class) .defaultsTo("null"); }
static OptionSpec<Integer> compressionLevelOption(OptionParser optParser) { return optParser .accepts("level", "Compression level (only applies to deflate and xz)") .withRequiredArg() .ofType(Integer.class) .defaultsTo(Deflater.DEFAULT_COMPRESSION); }
.withRequiredArg() .ofType(ClientUpdateCheckMode.class) .defaultsTo(ClientUpdateCheckMode.AUTO) .withValuesConvertedBy(new EnumConverter<ClientUpdateCheckMode>(ClientUpdateCheckMode.class)
protected void addOption(OptionParser parser, OptionMetadata option) { // ensure non-null description String description = Optional.ofNullable(option.getDescription()).orElse(""); // TODO: how do we resolve short name conflicts? List<String> longAndShort = asList(option.getShortName(), option.getName()); OptionSpecBuilder optionBuilder = parser.acceptsAll(longAndShort, description); switch (option.getValueCardinality()) { case OPTIONAL: ArgumentAcceptingOptionSpec<String> optionSpec = optionBuilder.withOptionalArg().describedAs(option.getValueName()); if(option.getDefaultValue() != null) { optionSpec.defaultsTo(option.getDefaultValue()); } break; case REQUIRED: optionBuilder.withRequiredArg().describedAs(option.getValueName()); break; default: break; } }
p.accepts("codec", "Compression codec") .withRequiredArg() .defaultsTo("null") .ofType(String.class); OptionSet opts = p.parse(args.toArray(new String[0]));
.withRequiredArg() .ofType(Long.class) .defaultsTo(new Long(0)); OptionSpec<Long> limitOpt = optParser .accepts("limit", "maximum number of records in the outputfile") .withRequiredArg() .ofType(Long.class) .defaultsTo(Long.MAX_VALUE); OptionSpec<Double> fracOpt = optParser .accepts("samplerate", "rate at which records will be collected") .withRequiredArg() .ofType(Double.class) .defaultsTo(new Double(1));
.ofType(String.class) .describedAs("log config file path.") .defaultsTo("./src/main/config/log4j.properties"); .defaultsTo("input.png"); acceptsAll(Arrays.asList("u", "url")).withRequiredArg() .ofType(String.class) .describedAs("URL to encode") .defaultsTo("http://free6om.me"); .defaultsTo(6); acceptsAll(Arrays.asList("m", "mask")).withRequiredArg() .ofType(Integer.class) .describedAs("QR mask: 0 - 7") .defaultsTo(2); acceptsAll(Arrays.asList("q", "quiet")).withRequiredArg() .ofType(Integer.class) .describedAs("QR quiet zone") .defaultsTo(2); acceptsAll(Arrays.asList("r", "rotation")).withRequiredArg() .ofType(Integer.class) .describedAs("rotation of the image in clockwise: 0 - 3") .defaultsTo(0); acceptsAll(Arrays.asList("z", "size")).withRequiredArg() .ofType(Integer.class) .describedAs("output QR code size, 0 means don't scale") .defaultsTo(0); acceptsAll(Arrays.asList("cb", "colorBlack")).withOptionalArg() .ofType(String.class)
.describedAs("zone id") .ofType(Integer.class) .defaultsTo(-1); parser.accepts("stores", "store") .withRequiredArg() .describedAs("number of operations allowed per second per store") .ofType(Integer.class) .defaultsTo(100); parser.accepts("delete-all-versions", "Deletes all versions for a given key") .withOptionalArg(); .describedAs("Delete keys belonging to a node") .ofType(Integer.class) .defaultsTo(-1); parser.accepts("admin-url", "admin url").withRequiredArg().describedAs("admin url"); parser.accepts("check-keys-exist", "Verify if the number of keys exist") .describedAs("Check if the given number of keys exist in the store") .ofType(Integer.class) .defaultsTo(100); return parser;
/** * Return args parser * * @return program parser * */ private static OptionParser getParser() { OptionParser parser = new OptionParser(); parser.accepts("help", "print help information"); parser.accepts("url", "[REQUIRED] bootstrap URL") .withRequiredArg() .describedAs("bootstrap-url for the cluster in which a node is to be replaced") .ofType(String.class); parser.accepts("node", "[REQUIRED] node id.") .withRequiredArg() .describedAs("node id which needs to be replaced by the new node") .ofType(Integer.class); parser.accepts("newurl", "[REQUIRED] new bootstrap-url") .withRequiredArg() .describedAs("bootstrap-url for the new cluster, which will replace the node id") .ofType(String.class); parser.accepts("skip-restore", "do not restore data from existing machine"); parser.accepts("parallelism", "parallel data restores.") .withRequiredArg() .describedAs("number of data restores to happen in parallel") .ofType(Integer.class) .defaultsTo(3); return parser; }
.describedAs("overwriteExistingValue") .ofType(Boolean.class) .defaultsTo(false); parser.accepts(IGNORE_SCHEMA_MISMATCH, IGNORE_SCHEMA_WARNING_MESSAGE ) .withOptionalArg() .describedAs("ignoreSchemaMismatch") .ofType(Boolean.class) .defaultsTo(false);
.withRequiredArg().describedAs("topic").ofType(String.class); ArgumentAcceptingOptionSpec<Integer> partitionOpt = parser.accepts("partition", "partition id")// .withRequiredArg().describedAs("partition_id").ofType(Integer.class).defaultsTo(0); ArgumentAcceptingOptionSpec<Long> timeOpt = parser .accepts("time", "unix time(ms) of the offsets. -1: lastest; -2: earliest; unix million seconds: offset before this time")// .withRequiredArg().describedAs("unix_time").ofType(Long.class).defaultsTo(-1L); ArgumentAcceptingOptionSpec<Integer> noffsetsOpt = parser.accepts("offsets", "number of offsets returned")// .withRequiredArg().describedAs("count").ofType(Integer.class).defaultsTo(1); OptionSet options = parser.parse(args); checkRequiredArgs(parser, options, urlOpt, topicOpt, timeOpt);
ArgumentAcceptingOptionSpec<Integer> countOpt = parser.accepts("c", "max count mesages.")// .withRequiredArg().describedAs("count")// .ofType(Integer.class).defaultsTo(-1); ArgumentAcceptingOptionSpec<String> fileOpt = parser.accepts("file", "decode file list")// .withRequiredArg().ofType(String.class).describedAs("filepath");
.withRequiredArg().describedAs("jafka://hostname:port").ofType(String.class); ArgumentAcceptingOptionSpec<Long> offsetOpt = parser.accepts("offset", "The offset to start consuming from.")// .withRequiredArg().describedAs("offset").ofType(Long.class).defaultsTo(0L);
.withRequiredArg().describedAs("urls").ofType(String.class); final ArgumentAcceptingOptionSpec<String> groupIdOpt = parser.accepts("group", "The group id to consume on.")// .withRequiredArg().describedAs("gid").defaultsTo("console-consumer-" + new Random().nextInt(100000)).ofType(String.class); ArgumentAcceptingOptionSpec<Integer> fetchSizeOpt = parser.accepts("fetch-size", "The amount of data to fetch in a single request.")// .withRequiredArg().describedAs("size").ofType(Integer.class).defaultsTo(1024 * 1024); ArgumentAcceptingOptionSpec<Integer> socketBufferSizeOpt = parser.accepts("socket-buffer-size", "The size of the tcp RECV size.")// .withRequiredArg().describedAs("size").ofType(Integer.class).defaultsTo(2 * 1024 * 1024); ArgumentAcceptingOptionSpec<Integer> consumerTimeoutMsOpt = parser .accepts("consumer-timeout-ms", "consumer throws timeout exception after waiting this much " + "of time without incoming messages")// .withRequiredArg().describedAs("prop").ofType(Integer.class).defaultsTo(-1); ArgumentAcceptingOptionSpec<String> messageFormatterOpt = parser .accepts("formatter", "The name of a class to use for formatting jafka messages for display.").withRequiredArg().describedAs("class") .ofType(String.class).defaultsTo(NewlineMessageFormatter.class.getName()); ArgumentAcceptingOptionSpec<Integer> autoCommitIntervalOpt = parser .accepts("autocommit.interval.ms", "The time interval at which to save the current offset in ms")// .withRequiredArg().describedAs("ms").ofType(Integer.class).defaultsTo(10 * 1000);
.withRequiredArg().describedAs("broker_list").ofType(String.class); final ArgumentAcceptingOptionSpec<String> messageReaderOpt = parser.accepts("message-encoder", "The class name of the message encoder")// .withRequiredArg().describedAs("encoder_class").ofType(String.class).defaultsTo(LineMessageReader.class.getName());
.withOptionalArg().describedAs("partition").ofType(int.class).defaultsTo(1); parser.acceptsAll(Arrays.asList("e", "enlarge"), "enlarge partition number if exists");
.withRequiredArg() .ofType(String.class) .defaultsTo("localhost:9092") .describedAs("urls"); zookeeperOption = optionParser.accepts("zookeeper", "Format: HOST:POST") .withRequiredArg() .ofType(String.class) .defaultsTo("localhost:2181") .describedAs("url"); inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics")
.withRequiredArg() .ofType(String.class) .defaultsTo("localhost:9092") .describedAs("urls"); inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics. For these topics, the tool will reset the offset to the earliest available offset.")
.withRequiredArg() .ofType(String.class) .defaultsTo("localhost:9092") .describedAs("urls"); inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics. For these topics, the tool will reset the offset to the earliest available offset.")
.withRequiredArg() .ofType(String.class) .defaultsTo("localhost:9092") .describedAs("urls"); inputTopicsOption = optionParser.accepts("input-topics", "Comma-separated list of user input topics. For these topics, the tool will reset the offset to the earliest available offset.")