HBASE-7972 allow configuring the TCP backlog on thrift services.

Author: Jean-Daniel Cryans
Ammending-Author: Esteban Gutierrez
Ammending-Author: Sean Busbey
This commit is contained in:
Sean Busbey 2014-06-24 18:05:47 -07:00
parent 15a88d2e1b
commit 3aa2b2d638
2 changed files with 18 additions and 4 deletions

View File

@ -171,6 +171,7 @@ public class ThriftServerRunner implements Runnable {
* The thrift server and the HBase cluster must run in secure mode.
*/
static final String THRIFT_QOP_KEY = "hbase.thrift.security.qop";
static final String BACKLOG_CONF_KEY = "hbase.regionserver.thrift.backlog";
private static final String DEFAULT_BIND_ADDR = "0.0.0.0";
public static final int DEFAULT_LISTEN_PORT = 9090;
@ -515,6 +516,9 @@ public class ThriftServerRunner implements Runnable {
"-" + BIND_CONF_KEY + " not supported with " + implType);
}
// Thrift's implementation uses '0' as a placeholder for 'use the default.'
int backlog = conf.getInt(BACKLOG_CONF_KEY, 0);
if (implType == ImplType.HS_HA || implType == ImplType.NONBLOCKING ||
implType == ImplType.THREADED_SELECTOR) {
@ -560,7 +564,8 @@ public class ThriftServerRunner implements Runnable {
InetAddress listenAddress = getBindAddress(conf);
TServerTransport serverTransport = new TServerSocket(
new InetSocketAddress(listenAddress, listenPort));
new TServerSocket.ServerSocketTransportArgs().
bindAddr(new InetSocketAddress(listenAddress, listenPort)).backlog(backlog));
TBoundedThreadPoolServer.Args serverArgs =
new TBoundedThreadPoolServer.Args(serverTransport, conf);

View File

@ -107,6 +107,8 @@ public class ThriftServer extends Configured implements Tool {
*/
static final String THRIFT_QOP_KEY = "hbase.thrift.security.qop";
static final String BACKLOG_CONF_KEY = "hbase.regionserver.thrift.backlog";
public static final int DEFAULT_LISTEN_PORT = 9090;
@ -269,9 +271,12 @@ public class ThriftServer extends Configured implements Tool {
TProcessor processor,
TTransportFactory transportFactory,
int workerThreads,
InetSocketAddress inetSocketAddress)
InetSocketAddress inetSocketAddress,
int backlog)
throws TTransportException {
TServerTransport serverTransport = new TServerSocket(inetSocketAddress);
TServerTransport serverTransport = new TServerSocket(
new TServerSocket.ServerSocketTransportArgs().
bindAddr(inetSocketAddress).backlog(backlog));
log.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
serverArgs.processor(processor);
@ -351,6 +356,9 @@ public class ThriftServer extends Configured implements Tool {
throw new RuntimeException("Could not parse the value provided for the port option", e);
}
// Thrift's implementation uses '0' as a placeholder for 'use the default.'
int backlog = conf.getInt(BACKLOG_CONF_KEY, 0);
// Local hostname and user name,
// used only if QOP is configured.
String host = null;
@ -479,7 +487,8 @@ public class ThriftServer extends Configured implements Tool {
processor,
transportFactory,
workerThreads,
inetSocketAddress);
inetSocketAddress,
backlog);
}
final TServer tserver = server;