HBASE-2155 Add the option to bind to a specific IP address to the Nonblocking Thrift servers (Liang Xie)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1376490 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bbe297121d
commit
f96e1641cf
|
@ -95,8 +95,7 @@ public class ThriftServer {
|
|||
private void processOptions(final String[] args) throws Exception {
|
||||
Options options = new Options();
|
||||
options.addOption("b", BIND_OPTION, true, "Address to bind " +
|
||||
"the Thrift server to. Not supported by the Nonblocking and " +
|
||||
"HsHa server [default: " + DEFAULT_BIND_ADDR + "]");
|
||||
"the Thrift server to. [default: " + DEFAULT_BIND_ADDR + "]");
|
||||
options.addOption("p", PORT_OPTION, true, "Port to bind to [default: " +
|
||||
DEFAULT_LISTEN_PORT + "]");
|
||||
options.addOption("f", FRAMED_OPTION, false, "Use framed transport");
|
||||
|
|
|
@ -133,11 +133,11 @@ public class ThriftServerRunner implements Runnable {
|
|||
|
||||
/** An enum of server implementation selections */
|
||||
enum ImplType {
|
||||
HS_HA("hsha", true, THsHaServer.class, false),
|
||||
NONBLOCKING("nonblocking", true, TNonblockingServer.class, false),
|
||||
HS_HA("hsha", true, THsHaServer.class, true),
|
||||
NONBLOCKING("nonblocking", true, TNonblockingServer.class, true),
|
||||
THREAD_POOL("threadpool", false, TBoundedThreadPoolServer.class, true),
|
||||
THREADED_SELECTOR(
|
||||
"threadedselector", true, TThreadedSelectorServer.class, false);
|
||||
"threadedselector", true, TThreadedSelectorServer.class, true);
|
||||
|
||||
public static final ImplType DEFAULT = THREAD_POOL;
|
||||
|
||||
|
@ -302,8 +302,9 @@ public class ThriftServerRunner implements Runnable {
|
|||
if (implType == ImplType.HS_HA || implType == ImplType.NONBLOCKING ||
|
||||
implType == ImplType.THREADED_SELECTOR) {
|
||||
|
||||
TNonblockingServerTransport serverTransport =
|
||||
new TNonblockingServerSocket(listenPort);
|
||||
InetAddress listenAddress = getBindAddress(conf);
|
||||
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(
|
||||
new InetSocketAddress(listenAddress, listenPort));
|
||||
|
||||
if (implType == ImplType.NONBLOCKING) {
|
||||
TNonblockingServer.Args serverArgs =
|
||||
|
|
|
@ -87,7 +87,7 @@ public class ThriftServer {
|
|||
private static Options getOptions() {
|
||||
Options options = new Options();
|
||||
options.addOption("b", "bind", true,
|
||||
"Address to bind the Thrift server to. Not supported by the Nonblocking and HsHa server [default: 0.0.0.0]");
|
||||
"Address to bind the Thrift server to. [default: 0.0.0.0]");
|
||||
options.addOption("p", "port", true, "Port to bind to [default: " + DEFAULT_LISTEN_PORT + "]");
|
||||
options.addOption("f", "framed", false, "Use framed transport");
|
||||
options.addOption("c", "compact", false, "Use the compact protocol");
|
||||
|
@ -235,15 +235,6 @@ public class ThriftServer {
|
|||
|
||||
boolean framed = cmd.hasOption("framed") || nonblocking || hsha;
|
||||
TTransportFactory transportFactory = getTTransportFactory(framed);
|
||||
|
||||
// TODO: Remove once HBASE-2155 is resolved
|
||||
if (cmd.hasOption("bind") && (nonblocking || hsha)) {
|
||||
log.error("The Nonblocking and HsHaServer servers don't support IP address binding at the moment." +
|
||||
" See https://issues.apache.org/jira/browse/HBASE-2155 for details.");
|
||||
printUsage();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
InetSocketAddress inetSocketAddress = bindToPort(cmd.getOptionValue("bind"), listenPort);
|
||||
|
||||
if (nonblocking) {
|
||||
|
|
Loading…
Reference in New Issue