You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hbase.apache.org by WangYQ <wa...@163.com> on 2015/12/23 07:07:44 UTC

questions on HConnectionImplementation and HTable in hbase0.98.10

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




Re:Re: questions on HConnectionImplementation and HTable in hbase0.98.10

Posted by WangYQ <wa...@163.com>.
to the first question, I just think the method to get hconnectionImplementation with managed equals true is useless, 
because we can not use this htable instance get htable, when getTable, exception

to the second problem, in class hconnectionmanager, line 798, 
we can assign a pool to a htable, this pool is completely managed by htable, has no relation with hconnection.
so when close htable, this pool keeps un-closed








At 2015-12-23 14:28:28, "Enis Söztutar" <en...@apache.org> wrote:
>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
>2.0.
>
>Check out these slide decks for more examples:
>
>https://www.dropbox.com/s/v1x3djtlp1qg204/HBase%201.0%20API%20Changes%20-%20Meetup%2010_15_2014.pdf?dl=0
>
>http://www.slideshare.net/enissoz/meet-hbase-10
>
>
>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.
>
>Enis
>
>
>
>On Tue, Dec 22, 2015 at 10:07 PM, WangYQ <wa...@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
>>
>>
>>
>>

Re: questions on HConnectionImplementation and HTable in hbase0.98.10

Posted by Enis Söztutar <en...@apache.org>.
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
2.0.

Check out these slide decks for more examples:

https://www.dropbox.com/s/v1x3djtlp1qg204/HBase%201.0%20API%20Changes%20-%20Meetup%2010_15_2014.pdf?dl=0

http://www.slideshare.net/enissoz/meet-hbase-10


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.

Enis



On Tue, Dec 22, 2015 at 10:07 PM, WangYQ <wa...@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
>
>
>
>