You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by mb...@apache.org on 2012/04/07 00:13:46 UTC

svn commit: r1310613 - in /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase: regionserver/HRegionThriftServer.java thrift/HBaseThreadPoolServer.java thrift/TBoundedThreadPoolServer.java thrift/ThriftServer.java

Author: mbautin
Date: Fri Apr  6 22:13:46 2012
New Revision: 1310613

URL: http://svn.apache.org/viewvc?rev=1310613&view=rev
Log:
[jira] [HBASE-5730] [89-fb] Make HRegionThriftServer's thread pool bounded

Summary: This JIRA is for a quick fix in 89-fb to reuse TBoundedThreadPoolServer
in HRegionThriftServer. We will address whatever problems HRegionThriftServer
still has in trunk in HBASE-5703.

Test Plan:
- Run unit tests.
- Enable embedded thrift server and use the native HBase client as a load test.
Monitor the number of thrift worker threads created.

Reviewers: kannan, alevchuk, schen

Reviewed By: kannan

Differential Revision: https://reviews.facebook.net/D2643

Added:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/TBoundedThreadPoolServer.java
      - copied, changed from r1310612, hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/HBaseThreadPoolServer.java
Removed:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/HBaseThreadPoolServer.java
Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java?rev=1310613&r1=1310612&r2=1310613&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionThriftServer.java Fri Apr  6 22:13:46 2012
@@ -19,7 +19,6 @@
 package org.apache.hadoop.hbase.regionserver;
 
 import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.util.List;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
@@ -35,28 +34,20 @@ import org.apache.hadoop.hbase.client.HT
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.filter.ColumnPrefixFilter;
-import org.apache.hadoop.hbase.thrift.generated.AlreadyExists;
-import org.apache.hadoop.hbase.thrift.generated.BatchMutation;
-import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
 import org.apache.hadoop.hbase.thrift.generated.Hbase;
 import org.apache.hadoop.hbase.thrift.generated.IOError;
 import org.apache.hadoop.hbase.thrift.generated.IllegalArgument;
-import org.apache.hadoop.hbase.thrift.generated.Mutation;
-import org.apache.hadoop.hbase.thrift.generated.TCell;
-import org.apache.hadoop.hbase.thrift.generated.TRegionInfo;
 import org.apache.hadoop.hbase.thrift.generated.TRowResult;
+import org.apache.hadoop.hbase.thrift.TBoundedThreadPoolServer;
+import org.apache.hadoop.hbase.thrift.ThriftMetrics;
 import org.apache.hadoop.hbase.thrift.ThriftServer;
-import org.apache.hadoop.hbase.thrift.ThriftServer.HBaseHandler;
 import org.apache.hadoop.hbase.thrift.ThriftUtilities;
-import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.thrift.TException;
 import org.apache.thrift.protocol.TBinaryProtocol;
 import org.apache.thrift.protocol.TCompactProtocol;
 import org.apache.thrift.protocol.TProtocolFactory;
-import org.apache.thrift.server.THsHaServer;
 import org.apache.thrift.server.TNonblockingServer;
 import org.apache.thrift.server.TServer;
-import org.apache.thrift.server.TThreadPoolServer;
 import org.apache.thrift.transport.TFramedTransport;
 import org.apache.thrift.transport.TNonblockingServerSocket;
 import org.apache.thrift.transport.TNonblockingServerTransport;
@@ -278,10 +269,20 @@ public class HRegionThriftServer extends
         } else {
           transportFactory = new TTransportFactory();
         }
-        LOG.info("starting HRegionServer ThreadPool Thrift server on " +
-                 listenAddress + ":" + this.port);
-        tserver = new TThreadPoolServer(processor, serverTransport,
-                                       transportFactory, protocolFactory);
+
+        TBoundedThreadPoolServer.Options serverOptions =
+            new TBoundedThreadPoolServer.Options(conf);
+
+        LOG.info("starting " + ThriftServer.THREAD_POOL_SERVER_CLASS.getSimpleName() + " on "
+            + listenAddress + ":" + Integer.toString(port)
+            + "; minimum number of worker threads="
+            + serverOptions.minWorkerThreads
+            + ", maximum number of worker threads="
+            + serverOptions.maxWorkerThreads + ", queued requests="
+            + serverOptions.maxQueuedRequests);
+        ThriftMetrics metrics = new ThriftMetrics(port, conf);
+        tserver = new TBoundedThreadPoolServer(processor, serverTransport,
+                                       transportFactory, protocolFactory, serverOptions, metrics);
       }
       tserver.serve();
     } catch (Exception e) {

Copied: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/TBoundedThreadPoolServer.java (from r1310612, hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/HBaseThreadPoolServer.java)
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/TBoundedThreadPoolServer.java?p2=hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/TBoundedThreadPoolServer.java&p1=hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/HBaseThreadPoolServer.java&r1=1310612&r2=1310613&rev=1310613&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/HBaseThreadPoolServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/TBoundedThreadPoolServer.java Fri Apr  6 22:13:46 2012
@@ -49,7 +49,7 @@ import com.google.common.util.concurrent
 /**
  * A thread pool server customized for HBase.
  */
-public class HBaseThreadPoolServer extends TServer {
+public class TBoundedThreadPoolServer extends TServer {
 
   private static final String QUEUE_FULL_MSG =
       "Queue is full, closing connection";
@@ -75,7 +75,7 @@ public class HBaseThreadPoolServer exten
       "hbase.thrift.maxQueuedRequests";
 
   private static final Log LOG = LogFactory.getLog(
-      HBaseThreadPoolServer.class.getName());
+      TBoundedThreadPoolServer.class.getName());
 
   /**
    * Time to wait after interrupting all worker threads. This is after a clean
@@ -109,7 +109,7 @@ public class HBaseThreadPoolServer exten
 
   private final ThriftMetrics metrics;
 
-  public HBaseThreadPoolServer(TProcessor processor,
+  public TBoundedThreadPoolServer(TProcessor processor,
       TServerTransport serverTransport,
       TTransportFactory transportFactory,
       TProtocolFactory protocolFactory,
@@ -150,7 +150,7 @@ public class HBaseThreadPoolServer exten
     Runtime.getRuntime().addShutdownHook(new Thread(getClass().getSimpleName() + "-shutdown-hook") {
       @Override
       public void run() {
-        HBaseThreadPoolServer.this.stop();
+        TBoundedThreadPoolServer.this.stop();
       }
     });
 

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java?rev=1310613&r1=1310612&r2=1310613&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java Fri Apr  6 22:13:46 2012
@@ -92,8 +92,8 @@ import org.apache.thrift.transport.TTran
  */
 public class ThriftServer {
 
-  private static final Class<? extends TServer>
-      THREAD_POOL_SERVER_CLASS = HBaseThreadPoolServer.class;
+  public static final Class<? extends TServer>
+      THREAD_POOL_SERVER_CLASS = TBoundedThreadPoolServer.class;
 
   /**
    * The HBaseHandler is a glue object that connects Thrift RPC calls to the
@@ -1123,23 +1123,23 @@ public class ThriftServer {
 
     // Make optional changes to the configuration based on command-line options
     if (cmd.hasOption("minWorkers")) {
-      conf.set(HBaseThreadPoolServer.MIN_WORKER_THREADS_CONF_KEY,
+      conf.set(TBoundedThreadPoolServer.MIN_WORKER_THREADS_CONF_KEY,
           cmd.getOptionValue("minWorkers"));
     }
 
     if (cmd.hasOption("workers")) {
-      conf.set(HBaseThreadPoolServer.MAX_WORKER_THREADS_CONF_KEY,
+      conf.set(TBoundedThreadPoolServer.MAX_WORKER_THREADS_CONF_KEY,
           cmd.getOptionValue("workers"));
     }
 
     if (cmd.hasOption("queue")) {
-      conf.set(HBaseThreadPoolServer.MAX_QUEUED_REQUESTS_CONF_KEY,
+      conf.set(TBoundedThreadPoolServer.MAX_QUEUED_REQUESTS_CONF_KEY,
           cmd.getOptionValue("queue"));
     }
 
     // Only instantiate this when finished modifying the configuration
-    HBaseThreadPoolServer.Options serverOptions =
-      new HBaseThreadPoolServer.Options(conf);
+    TBoundedThreadPoolServer.Options serverOptions =
+      new TBoundedThreadPoolServer.Options(conf);
 
     // Construct correct ProtocolFactory
     TProtocolFactory protocolFactory;
@@ -1187,7 +1187,8 @@ public class ThriftServer {
       } else {
         listenAddress = InetAddress.getLocalHost();
       }
-      TServerTransport serverTransport = new TServerSocket(new InetSocketAddress(listenAddress, listenPort));
+      TServerTransport serverTransport =
+          new TServerSocket(new InetSocketAddress(listenAddress, listenPort));
 
       // Construct correct TransportFactory
       TTransportFactory transportFactory;
@@ -1206,7 +1207,7 @@ public class ThriftServer {
           + serverOptions.maxWorkerThreads + ", queued requests="
           + serverOptions.maxQueuedRequests);
 
-      server = new HBaseThreadPoolServer(processor, serverTransport,
+      server = new TBoundedThreadPoolServer(processor, serverTransport,
           transportFactory, protocolFactory, serverOptions, metrics);
 
       if (server.getClass() != THREAD_POOL_SERVER_CLASS) {