Return-Path: Delivered-To: apmail-hadoop-zookeeper-user-archive@minotaur.apache.org Received: (qmail 1867 invoked from network); 29 Jun 2010 14:49:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Jun 2010 14:49:51 -0000 Received: (qmail 67443 invoked by uid 500); 29 Jun 2010 14:49:50 -0000 Delivered-To: apmail-hadoop-zookeeper-user-archive@hadoop.apache.org Received: (qmail 67396 invoked by uid 500); 29 Jun 2010 14:49:50 -0000 Mailing-List: contact zookeeper-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-user@hadoop.apache.org Delivered-To: mailing list zookeeper-user@hadoop.apache.org Received: (qmail 67388 invoked by uid 99); 29 Jun 2010 14:49:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jun 2010 14:49:49 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [69.147.107.20] (HELO mrout1-b.corp.re1.yahoo.com) (69.147.107.20) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jun 2010 14:49:44 +0000 Received: from [10.73.72.96] (wifi-72-96.greatamerica.corp.yahoo.com [10.73.72.96]) by mrout1-b.corp.re1.yahoo.com (8.13.8/8.13.8/y.out) with ESMTP id o5TEnAve043966 for ; Tue, 29 Jun 2010 07:49:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; s=serpent; d=yahoo-inc.com; c=nofws; q=dns; h=message-id:date:from:user-agent:mime-version:to:subject: references:in-reply-to:content-type:content-transfer-encoding; b=TAT8pSbXvBpeL8JgBGQp4zs/y7J0ydngWvFspbs4ybnpw4QO8v5RhZePmZ9ThjSm Message-ID: <4C2A07D5.7010204@yahoo-inc.com> Date: Tue, 29 Jun 2010 07:48:53 -0700 From: Benjamin Reed User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: "zookeeper-user@hadoop.apache.org" Subject: Re: Are Watchers execute sequentially or in parallel ? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org 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 children = zk.getChildren(path, this); > > //process children > > } > } > > > > 2) > > public class ChildrenWatcher implements Watcher{ > > public void process(WatchedEvent event) { > > //get children > List 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� >