diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java index c7af888728d19..361623cfda82d 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java @@ -30,10 +30,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; @@ -553,7 +552,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(); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/RPCCallBenchmark.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/RPCCallBenchmark.java index e87f4b2dc03be..1204aaa69b63c 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/RPCCallBenchmark.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/RPCCallBenchmark.java @@ -91,75 +91,75 @@ private void validateOptions() throws ParseException { private Options buildOptions() { Options opts = new Options(); opts.addOption( - Option.builder("s") - .longOpt("serverThreads") - .hasArg(true) - .argName("numthreads") - .desc("number of server threads (handlers) to run (or 0 to not run server)") - .build()); + Option.builder("s") + .longOpt("serverThreads") + .hasArg(true) + .argName("numthreads") + .desc("number of server threads (handlers) to run (or 0 to not run server)") + .build()); opts.addOption( - Option.builder("r") - .longOpt("serverReaderThreads") - .hasArg(true) - .argName("threads") - .desc("number of server reader threads to run") - .build()); + Option.builder("r") + .longOpt("serverReaderThreads") + .hasArg(true) + .argName("threads") + .desc("number of server reader threads to run") + .build()); opts.addOption( - Option.builder("c") - .longOpt("clientThreads") - .hasArg(true) - .argName("numthreads") - .desc("number of client threads to run (or 0 to not run client)") - .build()); + Option.builder("c") + .longOpt("clientThreads") + .hasArg(true) + .argName("numthreads") + .desc("number of client threads to run (or 0 to not run client)") + .build()); opts.addOption( - Option.builder("m") - .longOpt("messageSize") - .hasArg(true) - .argName("bytes") - .desc("size of call parameter in bytes") - .build()); + Option.builder("m") + .longOpt("messageSize") + .hasArg(true) + .argName("bytes") + .desc("size of call parameter in bytes") + .build()); opts.addOption( - Option.builder("t") - .longOpt("time") - .hasArg(true) - .argName("seconds") - .desc("number of seconds to run clients for") - .build()); + Option.builder("t") + .longOpt("time") + .hasArg(true) + .argName("seconds") + .desc("number of seconds to run clients for") + .build()); opts.addOption( - Option.builder("p") - .longOpt("port") - .hasArg(true) - .argName("port") - .desc("port to listen or connect on") - .build()); + Option.builder("p") + .longOpt("port") + .hasArg(true) + .argName("port") + .desc("port to listen or connect on") + .build()); opts.addOption( - Option.builder("h") - .longOpt("host") - .hasArg(true) - .argName("addr") - .desc("host to listen or connect on") - .build()); + Option.builder("h") + .longOpt("host") + .hasArg(true) + .argName("addr") + .desc("host to listen or connect on") + .build()); opts.addOption( - Option.builder("e") - .longOpt("engine") - .hasArg(true) - .argName("protobuf") - .desc("engine to use") - .build()); + Option.builder("e") + .longOpt("engine") + .hasArg(true) + .argName("protobuf") + .desc("engine to use") + .build()); opts.addOption( - Option.builder("?") - .longOpt("help") - .hasArg(false) - .desc("show this screen") - .build()); + Option.builder("?") + .longOpt("help") + .hasArg(false) + .desc("show this screen") + .build()); return opts; } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java index 592b0bdc4483e..84893a2eff050 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestGenericOptionsParser.java @@ -34,7 +34,6 @@ import java.util.Map; import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.math3.util.Pair; import org.apache.hadoop.conf.Configuration; @@ -198,10 +197,11 @@ public void testEmptyFilenames() throws Exception { @Test public void testCreateWithOptions() throws Exception { // Create new option newOpt - Option opt = OptionBuilder.withArgName("int") - .hasArg() - .withDescription("A new option") - .create("newOpt"); + + Option opt = Option.builder("newOpt").argName("int") + .hasArg() + .desc("A new option") + .build(); Options opts = new Options(); opts.addOption(opt); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/JMXGet.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/JMXGet.java index 6d4e6e1d26cec..21ce9711bc1bf 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/JMXGet.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/JMXGet.java @@ -39,7 +39,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; @@ -247,33 +246,33 @@ private static void err(String msg) { private static CommandLine parseArgs(Options opts, String... args) throws IllegalArgumentException { - Option jmx_service = Option.builder("service") + Option jmxService = Option.builder("service") .argName("NameNode|DataNode").hasArg() .desc("specify jmx service (NameNode by default)").build(); - Option jmx_server = Option.builder("server") + Option jmxServer = Option.builder("server") .argName("mbean server").hasArg() .desc("specify mbean server (localhost by default)").build(); - Option jmx_help = Option.builder("help").desc("print help").build(); + Option jmxHelp = Option.builder("help").desc("print help").build(); - Option jmx_port = Option.builder("port") + Option jmxPort = Option.builder("port") .argName("mbean server port") .hasArg().desc("specify mbean server port, " + "if missing - it will try to connect to MBean Server in the same VM").build(); - Option jmx_localVM = Option.builder("localVM") + Option jmxLocalVM = Option.builder("localVM") .argName("VM's connector url").hasArg() .desc("connect to the VM on the same machine;" + "\n use:\n jstat -J-Djstat.showUnsupported=true -snap | " + "grep sun.management.JMXConnectorServer.address\n " + "to find the url").build(); - opts.addOption(jmx_server); - opts.addOption(jmx_help); - opts.addOption(jmx_service); - opts.addOption(jmx_port); - opts.addOption(jmx_localVM); + opts.addOption(jmxServer); + opts.addOption(jmxHelp); + opts.addOption(jmxService); + opts.addOption(jmxPort); + opts.addOption(jmxLocalVM); CommandLine commandLine = null; CommandLineParser parser = new GnuParser(); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/pipes/Submitter.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/pipes/Submitter.java index 4ff6a3d842287..a6dd256c95f2d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/pipes/Submitter.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/pipes/Submitter.java @@ -345,12 +345,14 @@ static class CommandLineParser { void addOption(String longName, boolean required, String description, String paramName) { - Option option = Option.builder(longName).argName(paramName).hasArg().desc(description).required(required).build(); + Option option = Option.builder(longName).argName(paramName) + .hasArg().desc(description).required(required).build(); options.addOption(option); } void addArgument(String name, boolean required, String description) { - Option option = Option.builder().argName(name).hasArg().desc(description).required(required).build(); + Option option = Option.builder().argName(name) + .hasArg().desc(description).required(required).build(); options.addOption(option); } diff --git a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-blockgen/src/main/java/org/apache/hadoop/tools/dynamometer/blockgenerator/GenerateBlockImagesDriver.java b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-blockgen/src/main/java/org/apache/hadoop/tools/dynamometer/blockgenerator/GenerateBlockImagesDriver.java index a5f01c83d2d78..0f7624d2f8d3b 100644 --- a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-blockgen/src/main/java/org/apache/hadoop/tools/dynamometer/blockgenerator/GenerateBlockImagesDriver.java +++ b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-blockgen/src/main/java/org/apache/hadoop/tools/dynamometer/blockgenerator/GenerateBlockImagesDriver.java @@ -65,7 +65,8 @@ public GenerateBlockImagesDriver(Configuration conf) { public int run(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "help", false, "Shows this message"); - options.addOption(Option.builder(FSIMAGE_INPUT_PATH_ARG).argName("Input path of the XML fsImage") + options.addOption(Option.builder(FSIMAGE_INPUT_PATH_ARG) + .argName("Input path of the XML fsImage") .hasArg().required(true) .desc("Input path to the Hadoop fsImage XML file (required)") .build());