-Re: Watching children updates
kishore g 2013-07-18, 05:50
Good idea beware of failure scenarios.
lets say you do
#1. parent.setData #2 child.setData
your watch might be triggered and when you read the children child may not
be changed yet. so u will miss the child data change
other option is
#1 child.setData #2 parent.setData
if you fail after setting the child data, there wont be any watch triggered.
Only option is probably doing child.setData and parent.setData in the same
transaction and probably the multitransaction can be helpful. But if you
are updating children often the multitransaction might fail quite
frequently because of concurrent updates on the parent
I think its better for zk to solve this problem the right way. Instead of
solving the problem of large number of watches in zk, it might be a better
idea to add the concept of watching childDataChange in zookeeper. I dont
think the implementation will be any more complicated than triggering
watches for child creation.
On Wed, Jul 17, 2013 at 6:23 PM, Benjamin Jaton <[EMAIL PROTECTED]>wrote:
> Thanks, the JIRA is very interesting.
> I am contemplating the possibility to make a parent.setData(..) call to
> notify of a change in one of the children and put a watcher on
> I would then iterate through the children and compare the stat.getVersion()
> to figure out which have changed.
> On Wed, Jul 17, 2013 at 5:30 PM, Flavio Junqueira <[EMAIL PROTECTED]
> > Hi Ben,
> > Your description seems right to me, assuming that when you refer to
> > changes to the children, you mean setting the data of the children.
> > You may also want to have a look here if you haven't done it yet:
> > About performance impact, you may want to have a look at the discussion
> > here:
> > https://issues.apache.org/jira/browse/ZOOKEEPER-1177
> > -Flavio
> > On Jul 18, 2013, at 12:25 AM, Benjamin Jaton <[EMAIL PROTECTED]>
> > wrote:
> > > Hello,
> > >
> > > I would like to be notified of a change on any of the children of a
> > > (could be a lot of them).
> > >
> > > AFAIK to achieve this we need to set a watcher on each child and then
> > also
> > > watch the parent to be aware of children addition/deletion and
> > > watchers accordingly. Is that correct?
> > >
> > > What is the performance impact of having for example thousands of
> > watchers?
> > >
> > > Thanks,
> > > Ben