hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liu, Ming (HPIT-GADSC)" <ming.l...@hp.com>
Subject RE: HTable or HConnectionManager, how a client connect to HBase?
Date Tue, 24 Feb 2015 03:19:08 GMT
Thanks, Enis,

Your reply is very clear,  I finally understand it now.

Best Regards,
Ming
-----Original Message-----
From: Enis Söztutar [mailto:enis.soz@gmail.com] 
Sent: Thursday, February 19, 2015 10:41 AM
To: hbase-user
Subject: Re: HTable or HConnectionManager, how a client connect to HBase?

It is a bit more complex than that. It is actually a hash of some subset of the configuration
properties. See HConnectionKey class if you want to learn more. But the important thing is
that with the new style, you do not need to worry anything about these since there is no implicit
connection sharing. Everything is explicit now.

Enis

On Tue, Feb 17, 2015 at 11:50 PM, Serega Sheypak <serega.sheypak@gmail.com>
wrote:

> Hi, Enis Söztutar
> You've wrote:
> >>You are right that the constructor new HTable(Configuration, ..) 
> >>will
> share the underlying connection if same configuration object is used.
>
> What do it mean "the same"? is equality checked using reference (java 
> == ) or using equals(Object other) method?
>
>
> 2015-02-18 7:34 GMT+03:00 Enis Söztutar <enis.soz@gmail.com>:
>
> > Hi,
> >
> > You are right that the constructor new HTable(Configuration, ..) 
> > will
> share
> > the underlying connection if same configuration object is used.
> Connection
> > is a heavy weight object, that holds the zookeeper connection, rpc
> client,
> > socket connections to multiple region servers, master, and the 
> > thread
> pool,
> > etc. You definitely do not want to create multiple connections per
> process
> > unless you know what you are doing.
> >
> > The model is changed, and the old way of HTable(Configuration, ..) 
> > is deprecated because, we want to make the Connection lifecycle 
> > management explicit. In the new model, an opened Connection is 
> > closed by the user again, and light weight Table instances are obtained from the
Connection.
> > Having HTable's share their connections implicitly makes reasoning 
> > about
> it
> > too hard. The new model should be pretty easy to follow.
> >
> > Enis
> >
> > On Sat, Feb 14, 2015 at 6:45 AM, Liu, Ming (HPIT-GADSC) <
> ming.liu2@hp.com>
> > wrote:
> >
> > > Hi,
> > >
> > > I am using HBase 0.98.6.
> > >
> > > I learned from this maillist before, that the recommended method 
> > > to 'connect' to HBase from client is to use HConnectionManager like this:
> > >                                 HConnection 
> > > con=HConnectionManager.createConnection(configuration);
> > >                                 HTableInterfacetable = 
> > > con.getTable("hbase_table1"); Instead of
> > >                                 HTableInterface table = new 
> > > HTable(configuration, "hbase_table1");
> > >
> > > I don't quite understand the reason. I was thinking that each time 
> > > I initialize a HTable instance, it needs to create a new 
> > > HConnection. And that is expensive. But using the first method, 
> > > multiple HTable
> instances
> > > can share the same HConnection. That is quite reasonable to me.
> > > However, I was reading from some articles on internet that , even 
> > > if I
> > use
> > > the 'new HTable(conf, tbl)' method, if the 'conf' object is the 
> > > same
> one,
> > > all the HTable instances will still share the same HConnection. I 
> > > was recently read yet another article and said when using 'new 
> > > HTable(conf, tbl)', one don't need to use the exactly same 'conf' 
> > > object (same one
> in
> > > memory). if two 'conf' objects, two different objects are all the
> same, I
> > > mean all attributes of these two are same (for example, created 
> > > from
> the
> > > same hbase-site.xml and never change) then HTable objects can 
> > > still
> share
> > > the same HConnection.  I also try to read the HTable src code, it 
> > > is
> very
> > > hard, but it seems to me the last statement is correct: 'HTable 
> > > will
> > share
> > > HConnection, if configuration is all the same'.
> > >
> > > Sorry for so verbose. My question:
> > > If two 'configuration' objects are same, then two HTable object 
> > > instantiated with them respectively can still share the same
> HConnection
> > or
> > > not? Directly using the 'new HTable()' method.
> > > If the answer is 'yes', then why I still need the 
> > > HConnectionManager to create a shared connection?
> > > I am talking about 0.98.6.
> > > I googled for days, and even try to read HBase src code, but still 
> > > get really confused. I try to do some tests also, but since I am 
> > > too
> newbie,
> > I
> > > don't know how to verify the difference, I really don't know what 
> > > a HConnection do under the hood. I counted the ZooKeeper client 
> > > requests,
> > and
> > > I found some difference. If this ZooKeeper requests difference is 
> > > a
> > correct
> > > metrics, it means to me that two HTable do not share HConnetion 
> > > even
> > using
> > > same 'configuration' in the constructor. So it confused me more 
> > > and
> > more....
> > >
> > > Please someone kindly help me for this newbie question and thanks 
> > > in advance.
> > >
> > > Thanks,
> > > Ming
> > >
> > >
> > >
> >
>
Mime
View raw message