Hi, I'm using CDH 5.2, 0.98 I don't know how to use it correctly. I've just used this sample: https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HConnectionManager.html
HConnection connection = HConnectionManager.createConnection(config); HTableInterface table = connection.getTable(TableName.valueOf("table1")); try { // Use the table as needed, for a single operation and a single thread } finally { table.close(); connection.close(); } Functional testing OK, performance fails :(((( 2014-12-12 19:32 GMT+03:00 Stack <st...@duboce.net>: > > Does zk count go up on each request to the servlet? Which version of hbase > so can try on this end? Do you have some client-side log? Better if you > cache the connection rather than make it each time since setup is costly > but lets fix first problem first. > St.Ack > > On Fri, Dec 12, 2014 at 2:47 AM, Serega Sheypak <serega.shey...@gmail.com> > wrote: > > > Hi, I'm using HConnectionManager from java servlet > > Looks like it's leaking, all my zookeepers complains that there is too > many > > connections from servlet hosts. > > Typical line from lZK log: > > > > oo many connections from /my.tomcat.server.com - max is 60 > > > > > > Here is code sample > > > > public class BaseConnection { > > > > private static final Logger LOG = > > LoggerFactory.getLogger(BaseConnection.class); > > > > protected void close(HConnection connection){ > > try{ > > if(connection == null){ > > return; > > } > > connection.close(); > > } > > catch (Exception e){ > > LOG.warn("Error while closing HConnection", e); > > } > > } > > > > protected void close(HTableInterface hTable){ > > try{ > > if(hTable == null){ > > return; > > } > > hTable.close(); > > } > > catch (Exception e){ > > LOG.warn("Error while closing HTable", e); > > } > > } > > } > > > > sample PUT code from subclass: > > > > public void put(List<MyBean> entries){ > > HConnection hConnection = null; > > HTableInterface hTable = null; > > try { > > List<Put> puts = new ArrayList<Put>(entries.size()); > > for(MyBean myBean : entries){ > > puts.add(new MyBeanSerDe().createPut(myBean)); > > } > > hConnection = HConnectionManager.createConnection(configuration); > > hTable = hConnection.getTable(NAME_B); > > hTable.put(puts); > > > > }catch (Exception e){ > > LOG.error("Error while doing bulk put", e); > > }finally{ > > close(hTable); > > close(hConnection); > > } > > } > > >