hadoop-zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Reed <br...@yahoo-inc.com>
Subject Re: Are Watchers execute sequentially or in parallel ?
Date Tue, 29 Jun 2010 14:48:53 GMT
watchers are executed sequentially and in order. there is one dispatch 
thread that invokes the watch callbacks.

ben

ps - in 2) you do not install a watch.

On 06/29/2010 06:13 AM, André Oriani wrote:
> Hi,
>
> Are Watchers executed sequentially  or in parallel ? Suppose I want to
> monitor the children of a znode for any modification.  I don't want the same
> watcher to be re-executed while it is still executing.
>
>
>
> 1)
>
> public class ChildrenWatcher implements Watcher{
>
>       public void process(WatchedEvent event) {
>
>            //get children and install watcher
>            List<String>  children = zk.getChildren(path, this);
>
>                     //process children
>
>      }
> }
>
>
>
> 2)
>
> public class ChildrenWatcher implements Watcher{
>
>       public void process(WatchedEvent event) {
>
>            //get children
>            List<String>  children = zk.getChildren(path, null);
>
>                     //process children
>
>           //install watcher
>           zk.getChildren(path, null)
>      }
> }
>
>
>
> Does both code achieve the goal or just the code number 2 ?
>
>
> Tks,
> André
>    


Mime
View raw message