Avinash Lakshman wrote:
> Hi All
> I have a znode named /A. Now I will over time create znodes below it such
> /A/A1, /A/A2, ..., /A/An etc. Now every time I create this sub znode I need
> to have all my processes notified. Can I get by just setting one watch on
> /A? So my set up looks as follows:
> stat = zk_.exists(path + "/A", true);
> if ( stat == null )
> zk_.create("/A", new byte, Ids.OPEN_ACL_UNSAFE,
> This doesn't seem to trigger any watch when I add the sub znodes. What am I
> doing wrong
zk_.watchChildren( "/A", true )
What you are doing watches changes to the data at /A, not its children.
>From the javadocs:
Return the list of the children of the node of the given path.
If the watch is non-null and the call is successful (no exception is
thrown), a watch will be left on the node with the given path. The
watch willbe triggered by a successful operation that deletes the
node of the given path or creates/delete a child under the node.