I want to get notified whenever any sub znode is created under /A. Only one
process amongst many will create these sub znodes. But everyone needs to be
notified about this.

Cheers
Avinash

On Thu, Jun 4, 2009 at 12:38 PM, Eric Bowman <ebow...@boboco.ie> wrote:

> 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[0], Ids.OPEN_ACL_UNSAFE,
> > CreateMode.PERSISTENT);
> >  }
> >
> > This doesn't seem to trigger any watch when I add the sub znodes. What am
> I
> > doing wrong
>
> Try:
>
> zk_.watchChildren( "/A", true )
>
> What you are doing watches changes to the data at /A, not its children.
>
> From the javadocs:
>
>
>          getChildren
>
>    public List <
> http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true><String
> <
> http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true>>
> *getChildren*(String <
> http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true>
> path,
>                                    Watcher <
> http://hadoop.apache.org/zookeeper/docs/current/api/org/apache/zookeeper/Watcher.html>
> watcher)
>                             throws KeeperException <
> http://hadoop.apache.org/zookeeper/docs/current/api/org/apache/zookeeper/KeeperException.html
> >,
>                                    InterruptedException <
> http://java.sun.com/javase/6/docs/api/java/lang/InterruptedException.html?is-external=true
> >
>
>    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.
>
>
> cheers,
> Eric
>
> --
> Eric Bowman
> Boboco Ltd
> ebow...@boboco.ie
> http://www.boboco.ie/ebowman/pubkey.pgp
> +35318394189/+353872801532<http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532>
>
>

Reply via email to