Michi: By "client log" I assume you mean my product's log. I'll have to add some additional logging to indicate when it thinks it is connected -- or not. An excellent suggestion! Will work on that in the morning.
(It generally does connect because most/all of the configuration data I put in ZooKeeper is there. (I say "most/all" because I haven't verified every single config attribute.) Thanks! Chris From: Michi Mutsuzaki <[email protected]> To: "[email protected]" <[email protected]> Date: 01/15/2015 09:21 PM Subject: Re: ConnectionLossException Sent by: [email protected] 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 <[email protected]> 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
