zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michi Mutsuzaki <mi...@cs.stanford.edu>
Subject Re: ConnectionLossException
Date Fri, 16 Jan 2015 02:19:51 GMT
Hi Chris,

>From your code snippet, It is possible that the client didn't get
connected to ZooKeeper at all. Could you paste the entire client log?
Do you see any log message that indicates that the client got
connected to ZooKeeper?

On Thu, Jan 15, 2015 at 6:04 PM, Chris Barlock <barlock@us.ibm.com> wrote:
> We are currently using ZK 3.3.4, which is included in the version of Kafka
> we are using.  I'm seeing a number of exceptions like:
>
> org.apache.zookeeper.KeeperException$ConnectionLossException:
> KeeperErrorCode = ConnectionLoss for /com
>         at
> org.apache.zookeeper.KeeperException.create(KeeperException.java:90)
>         at
> org.apache.zookeeper.KeeperException.create(KeeperException.java:42)
>         at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:815)
>         at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:843)
>         at
> com.ibm.tivoli.ccm.config.rest.ConfigClient.setValueAtNode(ConfigClient.java:630)
>
> My method setValueAtNode includes a call to this method before I make any
> zk (ZooKeeper) calls:
>
>     private void connectZooKeeper() {
>         final String methodName = "connectZooKeeper";
>         trace.entry(CLASS_NAME, methodName);
>
>         if (zk == null || zk.getState() != States.CONNECTED) {
>             if (zk != null) {
>                 close();
>             }
>             try {
>                 zk = new ZooKeeper(connectString, sessionTimeout, this);
>                 int connectAttempts = 0;
>                 while (zk.getState() != States.CONNECTED &&
> connectAttempts < MAX_ZK_CONNECT_ATTEMPTS) {
>                     try {
>                         Thread.sleep(ZK_CONNECT_WAIT);
>                     } catch (InterruptedException e) {
>                         // Ignore
>                     }
>                     connectAttempts++;
>                 }
>             } catch (IOException e) {
>                 trace.exception(CLASS_NAME, methodName, e);
>             }
>         }
>
>         trace.exit(CLASS_NAME, methodName);
>     }
>
> I'm totally guessing that the connection is timing out between the time
> this method is called and when I make the following zk method calls.  Is
> there a best practise for ensuring one is connected to ZooKeeper?  My
> session timeout is 3000 ms.
>
> Chris

Mime
View raw message