On Wed, May 30, 2012 at 2:21 PM, Bogdan Odobas <[email protected]> wrote:
>
> 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?
> Thanks...

I'm having trouble making heads/tails of this because of the
formatting, could you fix the formatting? Or perhaps use gist (etc..)
to post.

Regards,

Patrick

Reply via email to