Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE-binary
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ com.squareup.okhttp3:okhttp:4.10.0
com.squareup.okio:okio:3.2.0
com.zaxxer:HikariCP:4.0.3
commons-beanutils:commons-beanutils:1.9.4
commons-cli:commons-cli:1.2
commons-cli:commons-cli:1.5.0
commons-codec:commons-codec:1.11
commons-collections:commons-collections:3.2.2
commons-daemon:commons-daemon:1.0.13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.audit.CommonAuditContext;
Expand Down Expand Up @@ -362,29 +361,28 @@ protected String getUsageMessage() {
/**
* Override point: create an options instance to combine with the
* standard options set.
* <i>Important. Synchronize uses of {@link OptionBuilder}</i>
* with {@code OptionBuilder.class}
* <i>Important. Synchronize uses of {@link Option}</i>
* with {@code Option.class}
* @return the new options
*/
@SuppressWarnings("static-access")
protected Options createOptions() {
synchronized (OptionBuilder.class) {
synchronized (Option.class) {
Options options = new Options();
Option oconf = OptionBuilder.withArgName("configuration file")
Option oconf = Option.builder(ARG_CONF_SHORT).argName("configuration file")
.hasArg()
.withDescription("specify an application configuration file")
.withLongOpt(ARG_CONF)
.create(ARG_CONF_SHORT);
Option confclass = OptionBuilder.withArgName("configuration classname")
.desc("specify an application configuration file")
.longOpt(ARG_CONF)
.build();
Option confclass = Option.builder(ARG_CONFCLASS_SHORT).argName("configuration classname")
.hasArg()
.withDescription(
"Classname of a Hadoop Configuration subclass to load")
.withLongOpt(ARG_CONFCLASS)
.create(ARG_CONFCLASS_SHORT);
Option property = OptionBuilder.withArgName("property=value")
.desc("Classname of a Hadoop Configuration subclass to load")
.longOpt(ARG_CONFCLASS)
.build();
Option property = Option.builder("D").argName("property=value")
.hasArg()
.withDescription("use value for given property")
.create('D');
.desc("use value for given property")
.build();
options.addOption(oconf);
options.addOption(property);
options.addOption(confclass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.MissingArgumentException;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.classification.InterfaceAudience;
Expand Down Expand Up @@ -230,8 +229,8 @@ public static void main(String[] args) throws IOException {
GenericOptionsParser genericParser = new GenericOptionsParser(args);
String[] remainingArgs = genericParser.getRemainingArgs();

Option conf = OptionBuilder.hasArg().create("conffile");
Option help = OptionBuilder.withLongOpt("help").create('h');
Option conf = Option.builder("conffile").hasArg().build();
Option help = Option.builder("h").longOpt("help").hasArg().build();
Options opts = new Options().addOption(conf).addOption(help);
CommandLineParser specificParser = new GnuParser();
CommandLine cmd = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.classification.InterfaceAudience;
Expand Down Expand Up @@ -225,51 +224,50 @@ public boolean isParseSuccessful() {

/**
* @return Specify properties of each generic option.
* <i>Important</i>: as {@link OptionBuilder} is not thread safe, subclasses
* must synchronize use on {@code OptionBuilder.class}
* <i>Important</i>: as {@link Option} is not thread safe, subclasses
* must synchronize use on {@code Option.class}
* @param opts input opts.
*/
@SuppressWarnings("static-access")
protected Options buildGeneralOptions(Options opts) {
synchronized (OptionBuilder.class) {
Option fs = OptionBuilder.withArgName("file:///|hdfs://namenode:port")
synchronized (Option.class) {
Option fs = Option.builder("fs").argName("file:///|hdfs://namenode:port")
.hasArg()
.withDescription("specify default filesystem URL to use, "
.desc("specify default filesystem URL to use, "
+ "overrides 'fs.defaultFS' property from configurations.")
.create("fs");
Option jt = OptionBuilder.withArgName("local|resourcemanager:port")
.build();
Option jt = Option.builder("jt").argName("local|resourcemanager:port")
.hasArg()
.withDescription("specify a ResourceManager")
.create("jt");
Option oconf = OptionBuilder.withArgName("configuration file")
.desc("specify a ResourceManager")
.build();
Option oconf = Option.builder("conf").argName("configuration file")
.hasArg()
.withDescription("specify an application configuration file")
.create("conf");
Option property = OptionBuilder.withArgName("property=value")
.desc("specify an application configuration file")
.build();
Option property = Option.builder("D").argName("property=value")
.hasArg()
.withDescription("use value for given property")
.create('D');
Option libjars = OptionBuilder.withArgName("paths")
.desc("use value for given property")
.build();
Option libjars = Option.builder("libjars").argName("paths")
.hasArg()
.withDescription(
"comma separated jar files to include in the classpath.")
.create("libjars");
Option files = OptionBuilder.withArgName("paths")
.desc("comma separated jar files to include in the classpath.")
.build();
Option files = Option.builder("files").argName("paths")
.hasArg()
.withDescription("comma separated files to be copied to the " +
.desc("comma separated files to be copied to the " +
"map reduce cluster")
.create("files");
Option archives = OptionBuilder.withArgName("paths")
.build();
Option archives = Option.builder("archives").argName("paths")
.hasArg()
.withDescription("comma separated archives to be unarchived" +
.desc("comma separated archives to be unarchived" +
" on the compute machines.")
.create("archives");
.build();

// file with security tokens
Option tokensFile = OptionBuilder.withArgName("tokensFile")
Option tokensFile = Option.builder("tokenCacheFile").argName("tokensFile")
.hasArg()
.withDescription("name of the file with the tokens")
.create("tokenCacheFile");
.desc("name of the file with the tokens")
.build();


opts.addOption(fs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.GnuParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -272,7 +271,7 @@ public MyOptions(String[] args) {

try {
Options opts = buildOptions();
CommandLineParser parser = new GnuParser();
CommandLineParser parser = new DefaultParser();
CommandLine line = parser.parse(opts, args, true);
processOptions(line, opts);
validateOptions();
Expand All @@ -290,81 +289,56 @@ public boolean proceed() {

private Options buildOptions() {
Option compress =
OptionBuilder.withLongOpt("compress").withArgName("[none|lzo|gz]")
.hasArg().withDescription("compression scheme").create('c');
Option.builder("c").longOpt("compress").argName("[none|lzo|gz]")
.hasArg().desc("compression scheme").build();

Option fileSize =
OptionBuilder.withLongOpt("file-size").withArgName("size-in-MB")
.hasArg().withDescription("target size of the file (in MB).")
.create('s');
Option.builder("s").longOpt("file-size").argName("size-in-MB")
.hasArg().desc("target size of the file (in MB).").build();

Option fsInputBufferSz =
OptionBuilder.withLongOpt("fs-input-buffer").withArgName("size")
.hasArg().withDescription(
"size of the file system input buffer (in bytes).").create(
'i');
Option.builder("i").longOpt("fs-input-buffer").argName("size")
.hasArg().desc("size of the file system input buffer (in bytes).").build();

Option fsOutputBufferSize =
OptionBuilder.withLongOpt("fs-output-buffer").withArgName("size")
.hasArg().withDescription(
"size of the file system output buffer (in bytes).").create(
'o');
Option.builder("o").longOpt("fs-output-buffer").argName("size")
.hasArg().desc("size of the file system output buffer (in bytes).").build();

Option keyLen =
OptionBuilder
.withLongOpt("key-length")
.withArgName("min,max")
.hasArg()
.withDescription(
"the length range of the key (in bytes)")
.create('k');
Option.builder("k").longOpt("key-length").argName("min,max")
.hasArg().desc("the length range of the key (in bytes)").build();

Option valueLen =
OptionBuilder
.withLongOpt("value-length")
.withArgName("min,max")
.hasArg()
.withDescription(
"the length range of the value (in bytes)")
.create('v');
Option.builder("v").longOpt("value-length").argName("min,max")
.hasArg().desc("the length range of the value (in bytes)").build();

Option blockSz =
OptionBuilder.withLongOpt("block").withArgName("size-in-KB").hasArg()
.withDescription("minimum block size (in KB)").create('b');
Option.builder("b").longOpt("block").argName("size-in-KB").hasArg()
.desc("minimum block size (in KB)").build();

Option seed =
OptionBuilder.withLongOpt("seed").withArgName("long-int").hasArg()
.withDescription("specify the seed").create('S');
Option.builder("S").longOpt("seed").argName("long-int").hasArg()
.desc("specify the seed").build();

Option operation =
OptionBuilder.withLongOpt("operation").withArgName("r|w|rw").hasArg()
.withDescription(
"action: seek-only, create-only, seek-after-create").create(
'x');
Option.builder("x").longOpt("operation").argName("r|w|rw").hasArg()
.desc("action: seek-only, create-only, seek-after-create").build();

Option rootDir =
OptionBuilder.withLongOpt("root-dir").withArgName("path").hasArg()
.withDescription(
"specify root directory where files will be created.")
.create('r');
Option.builder("r").longOpt("root-dir").argName("path").hasArg()
.desc("specify root directory where files will be created.").build();

Option file =
OptionBuilder.withLongOpt("file").withArgName("name").hasArg()
.withDescription("specify the file name to be created or read.")
.create('f');
Option.builder("f").longOpt("file").argName("name").hasArg()
.desc("specify the file name to be created or read.").build();

Option seekCount =
OptionBuilder
.withLongOpt("seek")
.withArgName("count")
.hasArg()
.withDescription(
"specify how many seek operations we perform (requires -x r or -x rw.")
.create('n');
Option.builder("n").longOpt("seek").argName("count").hasArg()
.desc("specify how many seek operations we perform (requires -x r or -x rw.").build();

Option help =
OptionBuilder.withLongOpt("help").hasArg(false).withDescription(
"show this screen").create("h");
Option.builder("h").longOpt("help").hasArg(false)
.desc("show this screen").build();

return new Options().addOption(compress).addOption(fileSize).addOption(
fsInputBufferSz).addOption(fsOutputBufferSize).addOption(keyLen)
Expand Down
Loading