Hi, I'm closing it in servlet.destroy. I didn't see any problems here for months. I'm using servlet lifecycle to deal with hconnection.
вторник, 17 февраля 2015 г. пользователь Liu, Ming (HPIT-GADSC) написал: > Hi, > > Thank you Serega for the helpful reply and thanks Jneidi for asking this. > I have similar confusion. > So Serega, when does your application finally close the HConnection? Or > the connection is NEVER closed as long as your application is running? Is > it OK to NOT close the HConnection and the application exit directly? > My application is a long-running service, accept user request and do CRUD > to hbase. So I would like to use your model here. But, is it reasonable to > keep that HConnection open a very long time, for example months? Is there > any potential problem I need to take care? > Also as David Chen asked, if all threads share same HConnection, it may > has limitation to support high throughput, so a pool of Connections maybe > better? > > Thanks, > Ming > > -----Original Message----- > From: Serega Sheypak [mailto:[email protected] <javascript:;>] > Sent: Wednesday, February 04, 2015 1:02 AM > To: user > Subject: Re: managing HConnection > > Hi, guys from group helped me a lot. I did solve pretty the same problem > (CRUD web-app) > > 1. Use single instance of HConnection per application. > 2. Instantiate it once. > 3. create HTable instance for each CRUD operation and safely close it > (try-catch-finally). Use the same HConnection to create any HTable for CRUD > operation. > 4. DO NOT close HConnection after CRUD operation > > I have logic controllers which get HConnection injection in > HttpServlet.init method. > So I have 5 HConnection instances per application created during servlet > initialization > > > 2015-02-03 18:12 GMT+03:00 Ted Yu <[email protected] <javascript:;>>: > > > Please see '61.1. Cluster Connections' under > > http://hbase.apache.org/book.html#architecture.client > > > > Cheers > > > > On Tue, Feb 3, 2015 at 6:47 AM, sleimanjneidi > > <[email protected] <javascript:;>> > > wrote: > > > > > Hi all, > > > I am using hbase-0.98.1-cdh5.1.4 client and I am a bit confused by > > > the documentation of HConnection. The document says the following: > > > > > > HConnection instances can be shared. Sharing is usually what you > > > want because rather than each HConnection instance having to do its > > > own discovery of regions out on the cluster, instead, all clients > > > get to > > share > > > the one cache of locations. HConnectionManager does the sharing for > > > you > > if > > > you go by it getting connections. Sharing makes cleanup of > > > HConnections awkward. . > > > > > > So now I have a simple question: Can I share the same HConnection > > instance > > > in my entire application? > > > And write some magic code to know when to close or never close at all? > > > Or I have to create an instance and close it every time I do a CRUD > > > operation ? > > > > > > Many thanks > > > > > > > > > > > >
