One approach is to iterate over the znode children and add data watcher to it. 
In the below example, I defined one single watcher instance which will handle 
the events and based on path it can act upon.

for example:

String parentPath = "/myparentnode"; // parent node which holds the children

Watcher w = new Watcher(){
       @Override
       public void process(WatchedEvent watchEvent) {
         //......write logic based on the znode child path
       }
}
// here it would be good to handle the KeeperExceptions 
// according to the business logic
for(String child : children){
   zk.getData(parentpath + "/" + path, w);
}

-Rakesh

-----Original Message-----
From: Kah-Chan Low [mailto:[email protected]] 
Sent: 16 January 2014 21:14
To: [email protected]
Subject: How to monitor changes in children's data

I am a novice.
I have a Znode and I want to get notified whenever anyone of the Znode's 
children has a change of data.
What kind of watch should I place on the Znode?

Thanks!

Reply via email to