hadoop-zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mahadev Konar <maha...@yahoo-inc.com>
Subject Re: How do I get added child znode?
Date Tue, 16 Feb 2010 18:49:57 GMT
Hi Kim,
  The zookeeper api does not provide an api to get the znode that was added
or deleted. You will have to compare the last set of children and new set of
children to see which one was added or deleted.

Thanks
mahadev


On 2/16/10 5:47 AM, "neptune" <openneptune@gmail.com> wrote:

> Hi all, I'm kimhj.
> 
> I have a question. I registered a Watcher on a parent znode("/foo").
> I create child znode("/foo/bar1") using a zookeeper console.
> Test program received Children changed event. But there is no API getting
> added znode.
> ZooKeeper.getChildren() method returns all children in a parent node.
> 
> public class ZkTest implements Watcher {
>   ZooKeeper zk;
>   public void test() {
>     zk = new ZooKeeper("127.0.0.1:2181", 10 * 1000, this);
>     zk.create("/foo", false);
>     zk.getChild("/foo", this);
>   }
> 
>   public void process(WatchedEvent event) {
>     if(event.getType() == Event.EventType.NodeChildrenChanged) {
>       *List<String> children = zk.getChildren(event.getPath(), this);*
>     }
>   }
> }
> 
> Thanks.


Mime
View raw message