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);
>     }
> }
>

Reply via email to