I see the problem, I need to put another watch after I receive the first event to get notified of the second event. Would it make sense then to have a watchChildren() method that sets the second watch but without returning the full children list? That way I can do getChildren() the first time and then a watchChildren() after each NodeChildrenChanged event, and update my local children list by added or removing the affected child which I somehow get from the event. And I dont have the redundant traffic of things already know going to all zookeepers.
Thanks for your fast response, Javier On Fri, May 8, 2009 at 1:01 PM, Benjamin Reed <br...@yahoo-inc.com> wrote: > i'm adding a faq on this right now. it's a rather common request. > > we could put in the name of the node that is changing. indeed, we did in the > first cut of zookeeper, but then we found that every instance of programs > that used this resulted in bugs, so we removed it. > > here is the problem: > > you do a getChildren(), an event comes in that "foo" is deleted, and right > afterwords "goo" gets deleted, but you aren't going to get that event since > the previous delete fired and you haven't done another getChildren(). this > almost always results in an error, so much so that we don't even give people > the rope. > > ben > > Javier Vegas wrote: >> >> Hi, I am starting to implement Zookeeper as an arbiter for a high >> performance client-server service, it is working really well but I >> have a question. When my Watcher receives an event of >> NodeChildrenChanged event, is there any way of getting from the event >> the path for the child that changed? The WatchedEvent javadoc says >> that it "includes exactly what happened" but all I am able to extract >> is a vague "NodeChildrenChanged" type. What I am doing now to figure >> out the path of teh new child is to do a new getChildren and compare >> the new children list with the old children list, but that seems a >> waste of time and bandwith if my node has lots of children and is >> watched by a loot of zookeepers (which will be in prod). If I can >> somehow get the path of the added/deleted child from the >> WatchedEvent, it will make my life easier and my Zookeeper-powered >> system much more simple, robust and scalable. Any suggestions? >> >> Thanks, >> >> Javier Vegas >> > >