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 HTable or HConnectionManager, how a client connect to HBase?
Date Sat, 14 Feb 2015 14:45:29 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message