zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bogdan Odobas <bodo...@hotmail.com>
Subject ZooKeeper question
Date Wed, 30 May 2012 21:21:41 GMT

Hi and thank you for help with this issue:
I have this piece of code:
@Overridepublic void process(WatchedEvent event) {		 if(Event.KeeperState.Disconnected ==
event.getState()){//	Client is not connected to any server in the ensemble	System.err.println(">>>Disconnected<<<");
System.err.println( zk.getState());...//    Here I have code that async waits for a bit then
closes the ZK if it cannot reconnect after a few attempts, because I only need ZK to read
some configuration. If not available, the config is read from a property file. I don't want
to try and keep reconnecting//start a new thread//in this thread, check if  zk.getState()
is not connected still.//if still not connected, wait for 10 seconds//if notified, means connected//if
the wait() time is up, it means not connected still. Close ZK}
The System.err.println( zk.getState()); prints "CONNECTED"
In other words, I get a disconnected event, but the ZK shows connected. So when the run()
method of the thread is entered, the first statement (if ( zk.getState()!= closed))  returns
true and it skips the rest.
Why ZK state is connected if I just got notified about a disconnect? Can I do something to
flush the state?
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message