hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [4/6] hbase git commit: HBASE-15637 TSHA Thrift-2 server should allow limiting call queue size
Date Thu, 14 Apr 2016 20:54:57 GMT
HBASE-15637 TSHA Thrift-2 server should allow limiting call queue size

Conflicts:
	hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a09ed496
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a09ed496
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a09ed496

Branch: refs/heads/0.98
Commit: a09ed49683551361947adcc1e6551799645f3058
Parents: 6f78c5a
Author: Mikhail Antonov <antonov@apache.org>
Authored: Tue Apr 12 14:46:22 2016 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Thu Apr 14 13:41:38 2016 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/thrift2/ThriftServer.java      | 23 +++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a09ed496/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftServer.java
----------------------------------------------------------------------
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 f633721..49c25b6 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
@@ -140,6 +140,8 @@ public class ThriftServer {
     options.addOption("f", "framed", false, "Use framed transport");
     options.addOption("c", "compact", false, "Use the compact protocol");
     options.addOption("w", "workers", true, "How many worker threads to use.");
+    options.addOption("q", "callQueueSize", true,
+      "Max size of request queue (unbounded by default)");
     options.addOption("h", "help", false, "Print help information");
     options.addOption(null, "infoport", true, "Port for web UI");
     options.addOption("t", READ_TIMEOUT_OPTION, true,
@@ -250,7 +252,7 @@ public class ThriftServer {
 
   private static TServer getTHsHaServer(TProtocolFactory protocolFactory,
       TProcessor processor, TTransportFactory transportFactory,
-      int workerThreads,
+      int workerThreads, int maxCallQueueSize,
       InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
       throws TTransportException {
     TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
@@ -260,7 +262,7 @@ public class ThriftServer {
       serverArgs.workerThreads(workerThreads);
     }
     ExecutorService executorService = createExecutor(
-        workerThreads, metrics);
+        workerThreads, maxCallQueueSize, metrics);
     serverArgs.executorService(executorService);
     serverArgs.processor(processor);
     serverArgs.transportFactory(transportFactory);
@@ -269,9 +271,14 @@ public class ThriftServer {
   }
 
   private static ExecutorService createExecutor(
-      int workerThreads, ThriftMetrics metrics) {
-    CallQueue callQueue = new CallQueue(
-        new LinkedBlockingQueue<Call>(), metrics);
+      int workerThreads, int maxCallQueueSize, ThriftMetrics metrics) {
+    CallQueue callQueue;
+    if (maxCallQueueSize > 0) {
+      callQueue = new CallQueue(new LinkedBlockingQueue<Call>(maxCallQueueSize), metrics);
+    } else {
+      callQueue = new CallQueue(new LinkedBlockingQueue<Call>(), metrics);
+    }
+
     ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
     tfb.setDaemon(true);
     tfb.setNameFormat("thrift2-worker-%d");
@@ -330,6 +337,7 @@ public class ThriftServer {
     Configuration conf = HBaseConfiguration.create();
     CommandLine cmd = parseArguments(conf, options, args);
     int workerThreads = 0;
+    int maxCallQueueSize = -1; // use unbounded queue by default
 
     /**
      * This is to please both bin/hbase and bin/hbase-daemon. hbase-daemon provides "start"
and "stop" arguments hbase
@@ -463,6 +471,10 @@ public class ThriftServer {
       workerThreads = Integer.parseInt(cmd.getOptionValue("w"));
     }
 
+    if (cmd.hasOption("q")) {
+      maxCallQueueSize = Integer.parseInt(cmd.getOptionValue("q"));
+    }
+
     // check for user-defined info server port setting, if so override the conf
     try {
       if (cmd.hasOption("infoport")) {
@@ -496,6 +508,7 @@ public class ThriftServer {
           processor,
           transportFactory,
           workerThreads,
+          maxCallQueueSize,
           inetSocketAddress,
           metrics);
     } else {


Mime
View raw message