ZooKeeper doesn’t support that. You’d need to set a watcher and then do your logic once the watcher triggers. What is the application here? I suggest looking at one of the Curator recipes such as NodeCache or PathChildrenCache.
-Jordan From: Giridhar Addepalli Giridhar Addepalli Reply: [email protected] [email protected] Date: March 5, 2014 at 12:01:55 AM To: [email protected] [email protected] Subject: Setting watch on node only if number of children is greater than zero Hi All, I am new to zookeeper/ curator. I want to setup watch on node if number of children is greater than zero. I can check number of children before setting the watch. But there could be a race condition in which , number of children of the node went to zero before setting up the watch and after checking for number of children. And this could lead to deadlock, because i will be listening for child removal event and there will be none. One way i could think of solving is polling for number of children in separate thread. But is there any cleaner approach via which i can avoid polling ? Thanks, Giridhar.
