Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
HBase, mail # user - how to work Htable connection


+
김인태 2012-11-05, 05:47
+
Suraj Varma 2012-11-06, 00:54
Copy link to this message
-
Re: how to work Htable connection
Leonid Fedotov 2012-11-05, 17:44
Hi!

As documentation stated:
HTable instances are not thread-safe. When creating HTable instances, it is advisable to use the same HBaseConfiguration instance. This will ensure sharing of ZooKeeper and socket instances to the RegionServers which is usually what you want.

Means that shared connection (method 1) is preferred.

As of your second question:
Client use zookeeper to find HBase master server, then consult with HBase master about region server(s) location(s) and then connect to region server(s) directly.
Thank you!

Sincerely,
Leonid Fedotov
On Nov 4, 2012, at 9:47 PM, 김인태 wrote:

> Hi. I am novice of hbase.
>
> I have some questions how to create htable,
>
> I read some blogs and hbase definitive guide book.
>
> First Question:
>
> They said that we can create htable with following two methods.
>
> First, sharing configuration
> Second, every new configuration instance
>
> There are a example in http://hbase.apache.org/book/client.html
>
> 1)
>
> HBaseConfiguration conf = HBaseConfiguration.create();
> HTable table1 = new HTable(conf, "myTable");
> HTable table2 = new HTable(conf, "myTable");
>
>
> 2)
>
> HBaseConfiguration conf1 = HBaseConfiguration.create();
> HTable table1 = new HTable(conf1, "myTable");
> HBaseConfiguration conf2 = HBaseConfiguration.create();
> HTable table2 = new HTable(conf2, "myTable");
>
>
> I can't understand difference of two implements. just instance count or
> connection?
>
> In the first samlpe, is it 1 connection instance?
> is it 2 connection instance in another sample?
>
> When I tested in 0.94.2, both created one zookeeper connection. so I have
> confused
>
>
> Second Question:
> When client get data in hbase, does a client connect only zookeeper or
> zookeeper and regionserver(not zookeeper)?
>
> Thanks!