Skip to content

Commit

Permalink
HADOOP-18359. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed May 7, 2023
1 parent 297c639 commit 798b33c
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 <vmpid> | "
+ "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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 798b33c

Please sign in to comment.