[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-1312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13161085#comment-13161085
 ] 

Ted Dunning commented on ZOOKEEPER-1312:
----------------------------------------

Another option would be to add one or a few comprehensive information files 
that contains information from all (some) of the children.

When a child is created, it would be created as an ephemeral with no content 
and the corresponding comprehensive file is updated in an atomic read-modify 
write way.

If the child departs in an orderly way, it could update the comprehensive file 
itself.  Otherwise, you should have one or more janitor processes that watches 
the directory with all the ephemerals and which updates the comprehensive file 
as needed.  The janitor could also be tasked with adding children to the 
comprehensive file if you like.

The virtue of this method is that you avoid the need for your stat operation 
since you can simply read the comprehensive files and know everything you need 
to know.  The anti-virtue is that there is a growing update which requires 
network traffic quadratic in the number of children being watched as nodes 
start or stop.  If you use the janitor to do the updates, you can moderate this 
cost by having the janitor update at a fixed maximum rate of, say once every 5 
seconds.  During startup, many children would appear during this 5 second 
interval so the number of updates would be radically decreased.

Another defect of this approach is that when children change their information, 
consumers of that information must read a relatively large chunk of information 
(the comprehensive file).
                
> Add a "getChildrenWithStat" operation
> -------------------------------------
>
>                 Key: ZOOKEEPER-1312
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1312
>             Project: ZooKeeper
>          Issue Type: New Feature
>            Reporter: Daniel Lord
>              Labels: newbie
>
> It would be extremely useful to be able to have a "getChildrenWithStat" 
> method.  This method would behave exactly the same as getChildren but in 
> addition to returning the list of all child znode names it would also return 
> a Stat for each child.  I'm sure there are quite a few use cases for this but 
> it could save a lot of extra reads for my application.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to