hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Srikanth P. Shreenivas" <Srikanth_Shreeni...@mindtree.com>
Subject RE: Usability improvement to HTablePool
Date Fri, 01 Jul 2011 14:42:27 GMT
This will be very helpful.  Also, wouldn't it be good idea to add close() to HTablePoolEnhanced
so that underlying HTables can be closed by client apps as part of application shutdown.


-----Original Message-----
From: Daniel Iancu [mailto:daniel.iancu@1and1.ro]
Sent: Friday, July 01, 2011 7:55 PM
To: user@hbase.apache.org
Subject: Usability improvement to HTablePool

It look like the usage of HTablePool might be improved. Now, once you
get the connection from pool you must take good care to return it by
calling  HTablePool.putTable(table);
If you close the table  (say, you don't read carefully the Javadoc)
your htable will not be reused.
Other case might be if you build a Datasource like object to obtain
HTables and, in this case, from the client you don't have a reference to
the pool to return the table once done with it.

I've fixed all this by subclassing the HTablePool and overriding the
getTable method

public class HTablePoolEnhanced extends HTablePool
     public HTableInterface getTable(String tableName) {
         return new PooledHTable(super.getTable(tableName));

  where  PooledHTable is a inner class that wraps a HTable and
reimplements the close method to return the table to pool

  public class PooledHTable implements HTableInterface {

         private HTableInterface table;

         public PooledHTable(HTableInterface table) {
             this.table = table;

         public void close() throws IOException {


Does it make sense to have this implementation in Hbase also ? It look
that all it needs is to have a new HTableInterfaceFactory implementation
to create some proxy tables like i did.




View raw message