HBASE-8921 [thrift2] Add GenericOptionsParser to Thrift 2 server

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1501982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lars George 2013-07-10 20:46:28 +00:00
parent 552932953f
commit 0ab9ab9ce7
1 changed files with 9 additions and 4 deletions

View File

@ -18,6 +18,7 @@
*/
package org.apache.hadoop.hbase.thrift2;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
@ -46,6 +47,7 @@ import org.apache.hadoop.hbase.thrift.CallQueue.Call;
import org.apache.hadoop.hbase.thrift.ThriftMetrics;
import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
import org.apache.hadoop.hbase.util.InfoServer;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
@ -105,9 +107,12 @@ public class ThriftServer {
return options;
}
private static CommandLine parseArguments(Options options, String[] args) throws ParseException {
private static CommandLine parseArguments(Configuration conf, Options options, String[] args)
throws ParseException, IOException {
GenericOptionsParser genParser = new GenericOptionsParser(conf, args);
String[] remainingArgs = genParser.getRemainingArgs();
CommandLineParser parser = new PosixParser();
return parser.parse(options, args);
return parser.parse(options, remainingArgs);
}
private static TProtocolFactory getTProtocolFactory(boolean isCompact) {
@ -222,7 +227,8 @@ public class ThriftServer {
TServer server = null;
Options options = getOptions();
try {
CommandLine cmd = parseArguments(options, args);
Configuration conf = HBaseConfiguration.create();
CommandLine cmd = parseArguments(conf, options, args);
/**
* This is to please both bin/hbase and bin/hbase-daemon. hbase-daemon provides "start" and "stop" arguments hbase
@ -245,7 +251,6 @@ public class ThriftServer {
boolean nonblocking = cmd.hasOption("nonblocking");
boolean hsha = cmd.hasOption("hsha");
Configuration conf = HBaseConfiguration.create();
ThriftMetrics metrics = new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.TWO);
String implType = "threadpool";