hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stack <st...@duboce.net>
Subject Re: HConnectionManager leaks with zookeeper conection oo many connections from /my.tomcat.server.com - max is 60
Date Fri, 12 Dec 2014 16:32:22 GMT
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.sheypak@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);
>     }
> }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message