[
https://issues.apache.org/jira/browse/HBASE-4054?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Iancu updated HBASE-4054:
--------------------------------
Description:
To improve the usability of the HTablePool the implementation should not rely
on the user returning the connection to the pool but rather do that
transparently when user closes the HTableImplementation it got.
To do that a HTableImplementation proxy implementation should be returned that
wraps a HTable object and holds a reference to the pool. When the client close
the proxy it will actually automatically return the wrapped HTable back in pool
to be reused. In this case the method HTablePool.putTable don't need to be
public
was:
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
> 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
>
>
> To improve the usability of the HTablePool the implementation should not rely
> on the user returning the connection to the pool but rather do that
> transparently when user closes the HTableImplementation it got.
>
> To do that a HTableImplementation proxy implementation should be returned
> that wraps a HTable object and holds a reference to the pool. When the client
> close the proxy it will actually automatically return the wrapped HTable back
> in pool to be reused. In this case the method HTablePool.putTable don't need
> to be public
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira