> 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
> http://zookeeper.wiki.sourceforge.net/ZooKeeperJavaExample that may give
> you some more ideas on how to simplify your code.
That would be nice.... simple is good!
Location: San Francisco, CA