Repository: hbase Updated Branches: refs/heads/branch-2 b52bf4052 -> b43a2eb49
HBASE-20358 Fix bin/hbase thrift usage text Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/b43a2eb4 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/b43a2eb4 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/b43a2eb4 Branch: refs/heads/branch-2 Commit: b43a2eb492ce55d4d6a7afa88d4172185e3b14cf Parents: b52bf40 Author: Balazs Meszaros <balazs.mesza...@cloudera.com> Authored: Fri Apr 6 17:41:03 2018 +0200 Committer: Michael Stack <st...@apache.org> Committed: Wed Apr 11 11:07:46 2018 -0700 ---------------------------------------------------------------------- .../hadoop/hbase/thrift/ThriftServer.java | 24 +++++--------------- .../hadoop/hbase/thrift2/ThriftServer.java | 19 ++++++---------- 2 files changed, 13 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/b43a2eb4/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java ---------------------------------------------------------------------- diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java index 33d16cb..8d8e74f 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java @@ -18,9 +18,6 @@ package org.apache.hadoop.hbase.thrift; -import java.util.Arrays; -import java.util.List; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseInterfaceAudience; @@ -33,9 +30,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine; import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser; +import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser; import org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter; import org.apache.hbase.thirdparty.org.apache.commons.cli.Options; -import org.apache.hbase.thirdparty.org.apache.commons.cli.PosixParser; /** * ThriftServer- this class starts up a Thrift server which implements the @@ -78,7 +75,8 @@ public class ThriftServer { throws ExitCodeException { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Thrift", null, options, - "To start the Thrift server run 'hbase-daemon.sh start thrift'\n" + + "To start the Thrift server run 'hbase-daemon.sh start thrift' or " + + "'hbase thrift'\n" + "To shutdown the thrift server run 'hbase-daemon.sh stop " + "thrift' or send a kill signal to the thrift server pid", true); @@ -143,20 +141,10 @@ public class ThriftServer { options.addOptionGroup(ImplType.createOptionGroup()); - CommandLineParser parser = new PosixParser(); + CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); - // This is so complicated to please both bin/hbase and bin/hbase-daemon. - // hbase-daemon provides "start" and "stop" arguments - // hbase should print the help if no argument is provided - List<String> commandLine = Arrays.asList(args); - boolean stop = commandLine.contains("stop"); - boolean start = commandLine.contains("start"); - boolean invalidStartStop = (start && stop) || (!start && !stop); - if (cmd.hasOption("help") || invalidStartStop) { - if (invalidStartStop) { - LOG.error("Exactly one of 'start' and 'stop' has to be specified"); - } + if (cmd.hasOption("help")) { printUsageAndExit(options, 1); } @@ -194,7 +182,7 @@ public class ThriftServer { conf, TBoundedThreadPoolServer.THREAD_KEEP_ALIVE_TIME_SEC_CONF_KEY); optionToConf(cmd, READ_TIMEOUT_OPTION, conf, ThriftServerRunner.THRIFT_SERVER_SOCKET_READ_TIMEOUT_KEY); - + // Set general thrift server options boolean compact = cmd.hasOption(COMPACT_OPTION) || conf.getBoolean(ThriftServerRunner.COMPACT_CONF_KEY, false); http://git-wip-us.apache.org/repos/asf/hbase/blob/b43a2eb4/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java ---------------------------------------------------------------------- diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java index fdd82cd..7a611c9 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java @@ -23,7 +23,6 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.security.PrivilegedAction; -import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; @@ -81,12 +80,12 @@ import org.slf4j.LoggerFactory; import org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder; import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine; import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser; +import org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser; import org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter; import org.apache.hbase.thirdparty.org.apache.commons.cli.Option; import org.apache.hbase.thirdparty.org.apache.commons.cli.OptionGroup; import org.apache.hbase.thirdparty.org.apache.commons.cli.Options; import org.apache.hbase.thirdparty.org.apache.commons.cli.ParseException; -import org.apache.hbase.thirdparty.org.apache.commons.cli.PosixParser; /** * ThriftServer - this class starts up a Thrift server which implements the HBase API specified in the @@ -129,9 +128,10 @@ public class ThriftServer extends Configured implements Tool { private static void printUsage() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Thrift", null, getOptions(), - "To start the Thrift server run 'hbase-daemon.sh start thrift2'\n" + - "To shutdown the thrift server run 'hbase-daemon.sh stop thrift2' or" + - " send a kill signal to the thrift server pid", + "To start the Thrift server run 'hbase-daemon.sh start thrift2' or " + + "'hbase thrift2'\n" + + "To shutdown the thrift server run 'hbase-daemon.sh stop thrift2' or" + + " send a kill signal to the thrift server pid", true); } @@ -166,7 +166,7 @@ public class ThriftServer extends Configured implements Tool { private static CommandLine parseArguments(Configuration conf, Options options, String[] args) throws ParseException, IOException { - CommandLineParser parser = new PosixParser(); + CommandLineParser parser = new DefaultParser(); return parser.parse(options, args); } @@ -385,12 +385,7 @@ public class ThriftServer extends Configured implements Tool { int selectorThreads = 0; int maxCallQueueSize = -1; // use unbounded queue by default - /** - * This is to please both bin/hbase and bin/hbase-daemon. hbase-daemon provides "start" and "stop" arguments hbase - * should print the help if no argument is provided - */ - List<?> argList = cmd.getArgList(); - if (cmd.hasOption("help") || !argList.contains("start") || argList.contains("stop")) { + if (cmd.hasOption("help")) { printUsage(); return 1; }