You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Ted Yu (JIRA)" <ji...@apache.org> on 2011/07/01 18:20:29 UTC

[jira] [Commented] (HBASE-4054) Usability improvement to HTablePool

    [ https://issues.apache.org/jira/browse/HBASE-4054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13058620#comment-13058620 ] 

Ted Yu commented on HBASE-4054:
-------------------------------

The way PooledHTable.close() is implemented would pose challenge to HTablePool's management of the size of its tables map, namely when maxSize is not Integer.MAX_VALUE.
Take a look at the following in HTablePool.putTable():
{code}
    if(tables.size(tableName) >= maxSize) {
      // release table instance since we're not reusing it
      this.tableFactory.releaseHTableInterface(table);
      return;
    }
{code}
In HTableFactory:
{code}
  public void releaseHTableInterface(HTableInterface table) throws IOException {
    table.close();
  }
{code}
So the intention of cleaning HTable instance ends up putting the instance back to the pool.

Looks like you need to implement your own HTableInterfaceFactory which would call realClose(), a method to be added to PooledHTable, to really close the instance for the above scenario.


> Usability improvement to HTablePool
> -----------------------------------
>
>                 Key: HBASE-4054
>                 URL: https://issues.apache.org/jira/browse/HBASE-4054
>             Project: HBase
>          Issue Type: Improvement
>          Components: client
>    Affects Versions: 0.90.3
>            Reporter: Daniel Iancu
>            Priority: Minor
>         Attachments: HBASE-4054_Usability_improvement_to_HTablePool.patch
>
>
> Hi
> 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
>     @Override
>      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;
>          }
>         @Override
>          public void close() throws IOException {
>              putTable(table);
>          }
>   ...
> }
> }
> 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.
> Regards
> Daniel

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira