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
This commit is contained in:
parent
983654d271
commit
2b88cdcd78
|
@ -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
|
||||
|
|
|
@ -103,6 +103,14 @@ public class ThriftServer {
|
|||
protected int nextScannerId = 0;
|
||||
protected HashMap<Integer, ResultScanner> scannerMap = null;
|
||||
|
||||
private static ThreadLocal<Map<String, HTable>> threadLocalTables = new ThreadLocal<Map<String, HTable>>() {
|
||||
@Override
|
||||
protected Map<String, HTable> initialValue() {
|
||||
return new TreeMap<String, HTable>();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 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<String, HTable> tables = threadLocalTables.get();
|
||||
if (!tables.containsKey(table)) {
|
||||
tables.put(table, new HTable(conf, tableName));
|
||||
}
|
||||
return tables.get(table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue