You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by Prasanna koirala <pk...@gmail.com> on 2017/12/22 04:09:30 UTC

Multiple watches in queue

Here is my problem
https://stackoverflow.com/questions/47924402/is-there-a-way-to-add-watcher-queue-in-zookeeper

Is there any solution to it ?? Any kind of research or work in progress ?

Re: Multiple watches in queue

Posted by Andor Molnar <an...@cloudera.com>.
Hi Prasanna,

I replied on the SO thread.

Regards,
Andor


On Fri, Dec 22, 2017 at 5:09 AM, Prasanna koirala <pk...@gmail.com>
wrote:

> Here is my problem
> https://stackoverflow.com/questions/47924402/is-there-a-
> way-to-add-watcher-queue-in-zookeeper
>
> Is there any solution to it ?? Any kind of research or work in progress ?
>

Re: Multiple watches in queue

Posted by timrc_us <ti...@yahoo.com>.
Hi Prasanna-

I can't speak to the javascript/node bindings, but in other languages, 
you call a single function that
both gets the current value *and* sets a watch simultaneously.
For example, in the c bindings, there's zoo_wget() :
https://github.com/apache/zookeeper/blob/master/src/c/include/zookeeper.h#L1748
which gets the current value in the node *and* sets a new watch for 
changes to it, atomically.
Similarly, there is zoo_wexists() and zoo_wgetchildren().

You may not get a notification for every individual change of the node 
(e.g. if the node changes after a
watch notice was sent back to you, but before you read the value and set 
a new watch).
However, you will get a watch notice sent back to you every time the 
node value is different from what
you last read. That is sufficient for most of the synchronization 
primitives folks need to make.

If you really need to know about every individual change (vs just making 
sure you're up-to-date),
then you'd probably have to do something like make each change a 
(sequential) child node and
have the watcher process delete them as they are handled.

Cheers!

.timrc


Prasanna koirala wrote:
> Here is my problem
> https://stackoverflow.com/questions/47924402/is-there-a-way-to-add-watcher-queue-in-zookeeper
>
> Is there any solution to it ?? Any kind of research or work in progress ?
>