You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2018/04/11 18:07:31 UTC
hbase git commit: HBASE-20358 Fix bin/hbase thrift usage text
Repository: hbase
Updated Branches:
refs/heads/branch-2.0 200afa195 -> 907b264ec
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/907b264e
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/907b264e
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/907b264e
Branch: refs/heads/branch-2.0
Commit: 907b264ec1f8d769002903bfe8d588ef1c8f552a
Parents: 200afa1
Author: Balazs Meszaros <ba...@cloudera.com>
Authored: Fri Apr 6 17:41:03 2018 +0200
Committer: Michael Stack <st...@apache.org>
Committed: Wed Apr 11 11:07:24 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/907b264e/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/907b264e/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;
}