curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <jor...@jordanzimmerman.com>
Subject Re: Setting watch on node only if number of children is greater than zero
Date Wed, 05 Mar 2014 11:03:18 GMT
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: user@curator.apache.org user@curator.apache.org
Date: March 5, 2014 at 12:01:55 AM
To: user@curator.apache.org user@curator.apache.org
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.



Mime
View raw message