org.apache.hadoop.hbase.client
Class HTablePool

java.lang.Object
  extended by org.apache.hadoop.hbase.client.HTablePool

public class HTablePool
extends Object

A simple pool of HTable instances.

Each HTablePool acts as a pool for all tables. To use, instantiate an HTablePool and use getTable(String) to get an HTable from the pool. Once you are done with it, return it to the pool with putTable(HTable).

A pool can be created with a maxSize which defines the most HTable references that will ever be retained for each table. Otherwise the default is Integer.MAX_VALUE.


Constructor Summary
HTablePool()
          Default Constructor.
HTablePool(HBaseConfiguration config, int maxSize)
          Constructor to set maximum versions and use the specified configuration.
 
Method Summary
 HTable getTable(byte[] tableName)
          Get a reference to the specified table from the pool.
 HTable getTable(String tableName)
          Get a reference to the specified table from the pool.
protected  HTable newHTable(String tableName)
          Deprecated. Use createHTable
 void putTable(HTable table)
          Puts the specified HTable back into the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTablePool

public HTablePool()
Default Constructor. Default HBaseConfiguration and no limit on pool size.


HTablePool

public HTablePool(HBaseConfiguration config,
                  int maxSize)
Constructor to set maximum versions and use the specified configuration.

Parameters:
config - configuration
maxSize - maximum number of references to keep for each table
Method Detail

getTable

public HTable getTable(String tableName)
Get a reference to the specified table from the pool.

Create a new one if one is not available.

Parameters:
tableName -
Returns:
a reference to the specified table
Throws:
RuntimeException - if there is a problem instantiating the HTable

getTable

public HTable getTable(byte[] tableName)
Get a reference to the specified table from the pool.

Create a new one if one is not available.

Parameters:
tableName -
Returns:
a reference to the specified table
Throws:
RuntimeException - if there is a problem instantiating the HTable

putTable

public void putTable(HTable table)
Puts the specified HTable back into the pool.

If the pool already contains maxSize references to the table, then nothing happens.

Parameters:
table -

newHTable

protected HTable newHTable(String tableName)
Deprecated. Use createHTable

Parameters:
tableName -
Returns:
HTable instance.


Copyright © 2010 The Apache Software Foundation