Is there any simple way to always be sure I have the latest state (data and/or children) of a node in Zookeeper using only watches and not polling, taking into account that the node may not exist when I start or may be deleted and recreated? I tried to do this, but doing so turned out to be complicated enough (in terms of setting up the multiple watches needed, and avoiding race conditions that could lead to data being dropped if the node is created or deleted at the wrong time) that I gave up and switched to polling. (Being a few seconds behind is no problem for my application, but missing a change is bad and missing all future changes is very bad.)
I'm using Curator in Java, which has recipes to make several things easier, but this doesn't appear to be one of them.
If you're using Curator, use NodeCache for a single node or PathChildrenCache for all the children of a node.
note: I'm the primary author of Curator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With