You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Gopala Krishna Gundeboyina <f2...@gmail.com> on 2012/11/29 12:26:15 UTC

watchers and multiple notifications

Hi All,

I am trying to understand the behavior of watches and need clarification on
two things:

Documentation says (
http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_WatchRememberThese
)

"*Be prepared to handle the case where the znode changes multiple times
between getting the event and setting the watch again. (You may not care,
but at least realize it may happen.)*"

1. Does this mean, once I set the watch again I am guaranteed to receive
one notification for all multiple events that I missed in the mean time
immediately? Or do I get a notification only when there is a new event?

2. Let say I got an event, before start handling the event I set the watch
again and got busy in the callback. Meanwhile I have multiple events. Are
these events result into one notification or multiple notifications?

In my system, I don't want to miss a notification at the same time I want
to handle an event just once if there are multiple notifications triggered
on it.

Thanks in Advance!
-gopala

Re: watchers and multiple notifications

Posted by Michi Mutsuzaki <mi...@cs.stanford.edu>.
Hi Gopala,

> 1. Does this mean, once I set the watch again I am guaranteed to receive
> one notification for all multiple events that I missed in the mean time
> immediately? Or do I get a notification only when there is a new event?

Latter. You will not get notifications for events that happened
between getting the event and setting the watch.

> 2. Let say I got an event, before start handling the event I set the watch
> again and got busy in the callback. Meanwhile I have multiple events. Are
> these events result into one notification or multiple notifications?

You will get a single notification for the first event. You will not
get any more notifications for subsequent events until you reset the
watch.

> In my system, I don't want to miss a notification at the same time I want
> to handle an event just once if there are multiple notifications triggered
> on it.

As far as I know, this is not possible with current zookeeper. I
remember somebody was talking about persistent watches in the last
zookeeper meetup, but I don't think the patch has been committed.

--Michi