2

I use ZooKeeper in my web Application and found a very odd issue: if I deploy two applications (both use zookeeper) to same tomcat, ZooKeeper in one app will inexplicable disconnect when tomcat starts.

Following is my code, which is very simple:

public class ZKTester implements InitializingBean, Watcher {

    private ZooKeeper hZooKeeper;

    public void afterPropertiesSet() throws Exception {
        hZooKeeper = new ZooKeeper("localhost:2181", 300000, this);
    }

    public void process(WatchedEvent event) {
        System.out.println("**************" + event);
    }

and the spring config file:

<bean id="zooTester" class="com.abc.framework.cluster.ZKTester"/>

And here is tomcat's startup log:

...
**************WatchedEvent state:Disconnected type:None path:null
**************WatchedEvent state:Expired type:None path:null
...

Are there any mistakes in my usage?

Thanks

L.J.W

cspann
  • 183
  • 1
  • 11
L.J.W
  • 1,575
  • 5
  • 18
  • 24

1 Answers1

0

From the ZooKeeper point of view the usage is correct. You can create multiple connections to a server.

What might be the problem is a property called maxClientCnxns that is present at the server and limits the connections from a single IP Adress. See the Zookeeper Documentation on maxClientCnxns for further details.

Regards, Christian

cspann
  • 183
  • 1
  • 11