I have a question. I registered a Watcher on a parent znode("/foo").
I create child znode("/foo/bar1") using a zookeeper console.
Test program received Children changed event. But there is no API getting
ZooKeeper.getChildren() method returns all children in a parent node.
getChildren is the correct way to access. When you get a notification
you don't know if one thing changed, or many. You are just getting a
notification that something has changed since you originally set the
watch. You need to determine what has changed. Typically it works like this:
1) getchildren(parent, watch)
2) process the result of get children call
3) wait for notification
4) when you get notification from 3), call getchildren(parent, watch)
again, notice that you are both getting the children and resetting the
watch. Without this step (test and set) you might miss notifications of
5) compare the data from 4 with the data from 1 - process any changes
See the recipes page http://bit.ly/938bnt for real world examples.