You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Parkirat Bagga <pa...@gmail.com> on 2012/10/19 07:43:45 UTC

Adding watcher on the same zk node multiple times - jute.maxbuffer

Hi,

I am using zookeerper version 3.3.3. My program is adding exists,
getchildren and getdata watchers on 1 zk node every 30 secs. We have other
watchers also.

The watcher object is singleton. So essentially, the watcher object which
gets attached is same every time.

So number of notifications comes for that node is only 1 when something
happens on that node.

Is it possible that this operation of adding same watcher multiple times
affect jute.maxbuffer limit in any way?

Does this operation add multiple watchers or the same watcher gets
overridden?

Regards,
Parkirat Singh Bagga. 



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Adding-watcher-on-the-same-zk-node-multiple-times-jute-maxbuffer-tp7578106.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Re: Adding watcher on the same zk node multiple times - jute.maxbuffer

Posted by Parkirat Bagga <pa...@gmail.com>.
Thanks Ben for the clarification.

Regards,
Parkirat Singh Bagga.



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Adding-watcher-on-the-same-zk-node-multiple-times-jute-maxbuffer-tp7578106p7578112.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Re: Adding watcher on the same zk node multiple times - jute.maxbuffer

Posted by Ben Bangert <be...@groovie.org>.
On Oct 19, 2012, at 4:01 AM, Parkirat Bagga <pa...@gmail.com> wrote:

> Thanks Daniel for the reply. 
> 
> My question is little different. May be I have not explained it well.
> 
> My question is,  I have a watcher object say "mywatch". 
> 
> Now, if on a zk node say "/mynode", I add "mywatch" watcher 400K times or
> more, and a disconnection happens at zk and all the watcher will get
> re-registered again. 
> 
> Can this result in connection - disconnection continuously, because of the
> value of jute.maxbuffer is 1mb?
> 
> I may get only 1 notification for all my watchers but, I want to know, if
> the same watcher is registered 400k times on the same node, there are
> actually 400k watchers present or its being overridden every time as its
> essentially the same watcher being registered on the same node.

If you make 400k objects, there are 400k watcher objects. Internally, the clients use a set per path and watch type, so that all 400k objects are tracked on the client-side as associated with the watch path/type. When the watch is triggered, the client goes through all 400k watch objects triggering them.

Technically, the Zookeeper protocol does not broadcast anything for disconnection, handling the disconnect and triggering all the watches is purely a client-side library implementation detail. If the client re-registers them, then its up to how the client implementation handles this. I'd imagine it would send 400k separate watch requests.

Now, if this watch object is not unique per call, that is you're using the same exact object and telling it to watch a node over and over, then its most likely registered just once client-side, and will result in just a single watch re-registration upon reconnect. This is because the internal implementation uses a set for the client-side watch path/type, and registering the same one over and over will not alter the set of unique watchers for the path/type.

Does that help?

Cheers,
Ben

Re: Adding watcher on the same zk node multiple times - jute.maxbuffer

Posted by Parkirat Bagga <pa...@gmail.com>.
Thanks Daniel for the reply. 

My question is little different. May be I have not explained it well.

My question is,  I have a watcher object say "mywatch". 

Now, if on a zk node say "/mynode", I add "mywatch" watcher 400K times or
more, and a disconnection happens at zk and all the watcher will get
re-registered again. 

Can this result in connection - disconnection continuously, because of the
value of jute.maxbuffer is 1mb?

I may get only 1 notification for all my watchers but, I want to know, if
the same watcher is registered 400k times on the same node, there are
actually 400k watchers present or its being overridden every time as its
essentially the same watcher being registered on the same node.

Regards,
Parkirat Singh Bagga.



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Adding-watcher-on-the-same-zk-node-multiple-times-jute-maxbuffer-tp7578106p7578110.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Re: Adding watcher on the same zk node multiple times - jute.maxbuffer

Posted by Daniel Gómez Ferro <da...@yahoo-inc.com>.

On Fri Oct 19 07:43:45 2012, Parkirat Bagga wrote:
> Hi,
>
> I am using zookeerper version 3.3.3. My program is adding exists,
> getchildren and getdata watchers on 1 zk node every 30 secs. We have other
> watchers also.
>
> The watcher object is singleton. So essentially, the watcher object which
> gets attached is same every time.
>
> So number of notifications comes for that node is only 1 when something
> happens on that node.
>
> Is it possible that this operation of adding same watcher multiple times
> affect jute.maxbuffer limit in any way?
>
> Does this operation add multiple watchers or the same watcher gets
> overridden?

If you add the same object as a watcher several times (for a given 
path) it will only be triggered once since ZK keeps a set of watcher 
objects per path. I don't know if this is stated on the documentation 
or the API.

Maybe a clarification should be added somewhere?

>
> Regards,
> Parkirat Singh Bagga.
>
>
>
> --
> View this message in context: http://zookeeper-user.578899.n2.nabble.com/Adding-watcher-on-the-same-zk-node-multiple-times-jute-maxbuffer-tp7578106.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.