HBASE-20358 Fix bin/hbase thrift usage text
This commit is contained in:
parent
072c503ec7
commit
1ad09d2f66
|
@ -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);
|
||||
|
@ -144,20 +142,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,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);
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,8 @@ public class ThriftServer extends Configured implements Tool {
|
|||
int selectorThreads = 0;
|
||||
int maxCallQueueSize = -1; // use unbounded queue by default
|
||||
|
||||
if (checkArguments(cmd)) {
|
||||
if (cmd.hasOption("help")) {
|
||||
printUsage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -545,19 +546,6 @@ public class ThriftServer extends Configured implements Tool {
|
|||
return implType;
|
||||
}
|
||||
|
||||
private boolean checkArguments(CommandLine cmd) {
|
||||
/*
|
||||
* 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")) {
|
||||
printUsage();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getBindAddress(Configuration conf, CommandLine cmd) {
|
||||
String bindAddress;
|
||||
if (cmd.hasOption("bind")) {
|
||||
|
|
Loading…
Reference in New Issue