From a17f9c13222a5b1b380015ba6b12a4baad708059 Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Tue, 24 Jun 2014 18:05:47 -0700 Subject: [PATCH] HBASE-7972 allow configuring the TCP backlog on thrift services. Author: Jean-Daniel Cryans Ammending-Author: Esteban Gutierrez Ammending-Author: Sean Busbey --- .../apache/hadoop/hbase/thrift/ThriftServerRunner.java | 7 ++++++- .../org/apache/hadoop/hbase/thrift2/ThriftServer.java | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java index 668aeb6..850f122 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServerRunner.java @@ -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); 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 7a808e0..632513b 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 @@ -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; -- 2.1.0