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(HTableInterface).

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.

Pool will manage its own cluster to the cluster. See HConnectionManager.


Constructor Summary
HTablePool()
          Default Constructor.
HTablePool(org.apache.hadoop.conf.Configuration config, int maxSize)
          Constructor to set maximum versions and use the specified configuration.
HTablePool(org.apache.hadoop.conf.Configuration config, int maxSize, HTableInterfaceFactory tableFactory)
           
 
Method Summary
 void closeTablePool(byte[] tableName)
          See closeTablePool(String).
 void closeTablePool(String tableName)
          Closes all the HTable instances , belonging to the given table, in the table pool.
protected  HTableInterface createHTable(String tableName)
           
 HTableInterface getTable(byte[] tableName)
          Get a reference to the specified table from the pool.
 HTableInterface getTable(String tableName)
          Get a reference to the specified table from the pool.
 void putTable(HTableInterface 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(org.apache.hadoop.conf.Configuration 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

HTablePool

public HTablePool(org.apache.hadoop.conf.Configuration config,
                  int maxSize,
                  HTableInterfaceFactory tableFactory)
Method Detail

getTable

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

Create a new one if one is not available.

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

getTable

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

Create a new one if one is not available.

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

putTable

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

If the pool already contains maxSize references to the table, then the table instance gets closed after flushing buffered edits.

Parameters:
table - table

createHTable

protected HTableInterface createHTable(String tableName)

closeTablePool

public void closeTablePool(String tableName)
Closes all the HTable instances , belonging to the given table, in the table pool.

Note: this is a 'shutdown' of the given table pool and different from putTable(HTableInterface), that is used to return the table instance to the pool for future re-use.

Parameters:
tableName -

closeTablePool

public void closeTablePool(byte[] tableName)
See closeTablePool(String).

Parameters:
tableName -


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.