Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to watch for events on all descendant nodes in ZooKeeper?

When using ZooKeeper is it possible to watch for all events on descendant znodes?

for example if I have:

     (/)
     /  \
   (/a)  (/b)
   /       \
(/c)       (/d)

Is there a way to watch the root for changes to /a, /b, /c and /d ?

like image 236
jdoig Avatar asked Aug 23 '12 18:08

jdoig


1 Answers

There is no ZooKeeper api to do that, you will have to write your own.

If you are using Curator, you can use PathCache which maintains watches on a node, and that node's children. You can write some code to create more PathCaches as you discover descendants of the root you are watching.

If you are going to roll your own version of this, it is actually quite tricky to get right. This blog describes some of the problems.

like image 121
sbridges Avatar answered Oct 26 '22 11:10

sbridges