hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Enis Söztutar <e...@apache.org>
Subject Re: questions on HConnectionImplementation and HTable in hbase0.98.10
Date Wed, 23 Dec 2015 06:28:28 GMT
A "managed" connection HConnection is a way that HBase auto-magically used
to handle connection lifecycle management and connection caching. However,
managed connections have been deprecated for some time and will be
completely removed by 2.0 timeframe.

You should look into only using un-managed connections whose lifecycle is
explicitly controlled by the client application. Connection is a heavy
weight thread-safe object and should be created once and shared across the
application, while Table/HTable instances are light-weight and should be
created per thread. Both Table and Connection instances should be closed as
appropriate. Notice that Connection and Table are very different objects
with different lifecycles. This affects how they can share a thread-pool
implementation. Un-managed connections will be the only supported way after

Check out these slide decks for more examples:



As per your questions, it is clear that this "auto-magical" management of
connection lifecycle is causing some confusion. You should notice that the
HConnectionManager.createConnection() methods taking managed as a parameter
are deprecated now. If you want to pass in a thread pool, you should use
un-managed connection. For the second question, the thread pool will be
owned by the HConnectionImplementation rather than being owned by HTable.
It will be closed by when HConnection is closed.


On Tue, Dec 22, 2015 at 10:07 PM, WangYQ <wangyongqiang0617@163.com> wrote:

> the version we use is hbase 0.98.10
> i have some doubt on  HConnectionImplementation and HTable
> 1. we can get a HConnectionImplementation using HConnectionManager using
> 'createConnection' method,  and we can set the parameter 'managed' to true
>     such as the method in class HConnectionManager, line 433
>     but if we use this HConnectionImplementation  to getTable, an
> exception will be thrown, because 'managed' is true, this exception is
> thrown in class HConnectionImplementation , line 809
> 2. when create htable using HConnectionImplementation, we can using the
> specified pool as the pool htable will use, when we close a htable, the
> pool will be shutdown only if 'cleanupPoolOnClose' is true, but htable get
> from HConnectionImplementation will use constructor in class HTable, line
> 328. cleanupPoolOnClose = false
> so, when we close htable instance, the pool will be kept un-closed

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message