Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E7449172FC for ; Wed, 13 May 2015 18:37:58 +0000 (UTC) Received: (qmail 66008 invoked by uid 500); 13 May 2015 18:37:58 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 65968 invoked by uid 500); 13 May 2015 18:37:58 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 65957 invoked by uid 99); 13 May 2015 18:37:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2015 18:37:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A8526DFF6A; Wed, 13 May 2015 18:37:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ndimiduk@apache.org To: commits@hbase.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-13201 Remove HTablePool from thrift-server (Solomon Duskis) Date: Wed, 13 May 2015 18:37:58 +0000 (UTC) Repository: hbase Updated Branches: refs/heads/branch-1.0 6cfc04d5a -> 7dfd43990 HBASE-13201 Remove HTablePool from thrift-server (Solomon Duskis) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/7dfd4399 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/7dfd4399 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/7dfd4399 Branch: refs/heads/branch-1.0 Commit: 7dfd4399053d06bad7d0d5dd3e538fdc5c4c5029 Parents: 6cfc04d Author: Nick Dimiduk Authored: Fri Mar 27 10:22:53 2015 -0700 Committer: Nick Dimiduk Committed: Wed May 13 11:31:53 2015 -0700 ---------------------------------------------------------------------- .../thrift2/ThriftHBaseServiceHandler.java | 69 ++++++++------------ 1 file changed, 27 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/7dfd4399/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java ---------------------------------------------------------------------- diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java index b055918..2a90765 100644 --- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java +++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftHBaseServiceHandler.java @@ -18,7 +18,18 @@ */ package org.apache.hadoop.hbase.thrift2; -import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.*; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.appendFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.deleteFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.deletesFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.getFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.getsFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.incrementFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.putFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.putsFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.resultFromHBase; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.resultsFromHBase; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.rowMutationsFromThrift; +import static org.apache.hadoop.hbase.thrift2.ThriftUtilities.scanFromThrift; import static org.apache.thrift.TBaseHelper.byteBufferToByteArray; import java.io.IOException; @@ -30,42 +41,40 @@ import java.nio.ByteBuffer; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.client.HTableFactory; -import org.apache.hadoop.hbase.client.HTableInterface; -import org.apache.hadoop.hbase.client.HTablePool; +import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.thrift.ThriftMetrics; -import org.apache.hadoop.hbase.thrift2.generated.*; +import org.apache.hadoop.hbase.thrift2.generated.TAppend; +import org.apache.hadoop.hbase.thrift2.generated.TDelete; +import org.apache.hadoop.hbase.thrift2.generated.TGet; +import org.apache.hadoop.hbase.thrift2.generated.THBaseService; +import org.apache.hadoop.hbase.thrift2.generated.TIOError; +import org.apache.hadoop.hbase.thrift2.generated.TIllegalArgument; +import org.apache.hadoop.hbase.thrift2.generated.TIncrement; +import org.apache.hadoop.hbase.thrift2.generated.TPut; +import org.apache.hadoop.hbase.thrift2.generated.TResult; +import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; +import org.apache.hadoop.hbase.thrift2.generated.TScan; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.ConnectionCache; import org.apache.thrift.TException; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; - /** * This class is a glue object that connects Thrift RPC calls to the HBase client API primarily * defined in the HTableInterface. */ @InterfaceAudience.Private -@SuppressWarnings("deprecation") public class ThriftHBaseServiceHandler implements THBaseService.Iface { // TODO: Size of pool configuraple - private final Cache htablePools; - private final Callable htablePoolCreater; private static final Log LOG = LogFactory.getLog(ThriftHBaseServiceHandler.class); // nextScannerId and scannerMap are used to manage scanner state @@ -75,8 +84,6 @@ public class ThriftHBaseServiceHandler implements THBaseService.Iface { new ConcurrentHashMap(); private final ConnectionCache connectionCache; - private final HTableFactory tableFactory; - private final int maxPoolSize; static final String CLEANUP_INTERVAL = "hbase.thrift.connection.cleanup-interval"; static final String MAX_IDLETIME = "hbase.thrift.connection.max-idletime"; @@ -123,34 +130,13 @@ public class ThriftHBaseServiceHandler implements THBaseService.Iface { int maxIdleTime = conf.getInt(MAX_IDLETIME, 10 * 60 * 1000); connectionCache = new ConnectionCache( conf, userProvider, cleanInterval, maxIdleTime); - tableFactory = new HTableFactory() { - @Override - public HTableInterface createHTableInterface(Configuration config, - byte[] tableName) { - try { - return connectionCache.getTable(Bytes.toString(tableName)); - } catch (IOException ioe) { - throw new RuntimeException(ioe); - } - } - }; - htablePools = CacheBuilder.newBuilder().expireAfterAccess( - maxIdleTime, TimeUnit.MILLISECONDS).softValues().concurrencyLevel(4).build(); - maxPoolSize = conf.getInt("hbase.thrift.htablepool.size.max", 1000); - htablePoolCreater = new Callable() { - public HTablePool call() { - return new HTablePool(conf, maxPoolSize, tableFactory); - } - }; } private Table getTable(ByteBuffer tableName) { - String currentUser = connectionCache.getEffectiveUser(); try { - HTablePool htablePool = htablePools.get(currentUser, htablePoolCreater); - return htablePool.getTable(byteBufferToByteArray(tableName)); - } catch (ExecutionException ee) { - throw new RuntimeException(ee); + return connectionCache.getTable(Bytes.toString(byteBufferToByteArray(tableName))); + } catch (IOException e) { + throw new RuntimeException(e); } } @@ -424,5 +410,4 @@ public class ThriftHBaseServiceHandler implements THBaseService.Iface { closeTable(htable); } } - }