Ben this is great, thanks! Do you want to close out this one and point to the faq?

Although IMO this should be moved to the forrest docs.


Benjamin Reed wrote:
I'm really bad a creating figures, but i've put up something that should be 
informative. (i'm also really bad at apache wiki.) hopefully someone can make 
it more beautiful. i've added the state diagram to the FAQ:


-----Original Message-----
From: [] On Behalf Of Adam 
Sent: Thursday, January 08, 2009 8:06 PM
Subject: Re: Updated NodeWatcher...

It feels like we need a flowchart, state-chart, or something, so we
can all talk about the same thing. Then people could suggest
abstractions that would essentially put a box around sections of the
diagram. However I feel woefully inadequate at the former :(.

.. Adam

On Thu, Jan 8, 2009 at 4:20 PM, Benjamin Reed <> wrote:
For your first issue if an ensemble goes offline and comes back, everything 
should be fine. it will look to the client just like a server went down. if a 
session expires, you are correct that the client will not reconnect. this again 
is on purpose. for the node watcher the session is unimportant, but if the 
ZooKeeper object is also being used for leader election, for example, you do 
not want the object to grab a new session automatically.

For 2) i think pat responded to that one. an async request will always return. 
if the server goes down after the request is issued, you will get a connection 
loss error in your callback.

Your third issued is described with the first.


-----Original Message-----
From: [] On Behalf Of Kevin 
Sent: Thursday, January 08, 2009 4:02 PM
Subject: Re: Updated NodeWatcher...

i just found that part of this thread went to my junk folder. can you send
the URL for the NodeListener?

Sure... here you go:

this NodeWatcher is a useful thing. i have a couple of suggestions to
simplify it:

1) Construct the NodeWatcher with a ZooKeeper object rather than
constructing one. Not only does it simplify NodeWatcher, but it also makes
it so that the ZooKeeper object can be used for other things as well.

I hear you.... I was thinking that this might not be a good idea because
NodeWatcher can reconnect you to the ensemble if it goes offline.

I'm not sure if it's a bug or not but once my session expired on the client
it wouldn't reconnect so I just implemented my own reconnect and session

2) Use the async API in watchNodeData and watchNodeExists. it simplifies
the code and the error handling.

The problem was that according to feedback here an async request might never
return if the server dies shortly after the request and before it has a
change to respond.

I wanted NodeWatcher to hide as much rope as possible.

3) You don't need to do a connect() in handleDisconnected(). ZooKeeper
object will do it automatically for you.

I can try again if you'd like by this isn't my experience.  Once the session
expired and the whole ensemble was offline it wouldn't connect again.

If it was a transient disconnect I'd see on disconnect event and then a
quick reconnect.  If it was a long disconnect (with nothing to attach to)
then ZK won't ever reconnect me.

I'd like this to be the behavior though...

There is an old example on sourceforge that may give
you some more ideas on how to simplify your code.

That would be nice.... simple is good!


Location: San Francisco, CA
AIM/YIM: sfburtonator
Skype: burtonator

Reply via email to