From 2b88cdcd781ec179ed7bc1a7351ef88c26b2368e Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 27 Apr 2010 04:14:37 +0000 Subject: [PATCH] HBASE-2393 ThriftServer instantiates a new HTable per request git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@938317 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../apache/hadoop/hbase/thrift/ThriftServer.java | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3682ca73fd6..953d3864f7d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -535,6 +535,8 @@ Release 0.21.0 - Unreleased (Benoit Sigoure via Stack) HBASE-2488 Master should warn more loudly about unexpected events (Todd Lipcon via Stack) + HBASE-2393 ThriftServer instantiates a new HTable per request + (Bogdan DRAGU via Stack) NEW FEATURES HBASE-1961 HBase EC2 scripts diff --git a/core/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java b/core/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java index 72851ac82d9..45d7910d9b3 100644 --- a/core/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java +++ b/core/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java @@ -103,6 +103,14 @@ public class ThriftServer { protected int nextScannerId = 0; protected HashMap scannerMap = null; + private static ThreadLocal> threadLocalTables = new ThreadLocal>() { + @Override + protected Map initialValue() { + return new TreeMap(); + } + + }; + /** * Returns a list of all the column families for a given htable. * @@ -131,7 +139,12 @@ public class ThriftServer { */ protected HTable getTable(final byte[] tableName) throws IOError, IOException { - return new HTable(this.conf, tableName); + String table = new String(tableName); + Map tables = threadLocalTables.get(); + if (!tables.containsKey(table)) { + tables.put(table, new HTable(conf, tableName)); + } + return tables.get(table); } /**