Return-Path: Delivered-To: apmail-hadoop-zookeeper-user-archive@minotaur.apache.org Received: (qmail 47460 invoked from network); 8 May 2009 20:37:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 May 2009 20:37:10 -0000 Received: (qmail 41728 invoked by uid 500); 8 May 2009 20:37:10 -0000 Delivered-To: apmail-hadoop-zookeeper-user-archive@hadoop.apache.org Received: (qmail 41688 invoked by uid 500); 8 May 2009 20:37:10 -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 41678 invoked by uid 99); 8 May 2009 20:37:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 May 2009 20:37:10 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of javier@beboinc.com designates 209.85.217.167 as permitted sender) Received: from [209.85.217.167] (HELO mail-gx0-f167.google.com) (209.85.217.167) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 May 2009 20:37:02 +0000 Received: by gxk11 with SMTP id 11so3126472gxk.5 for ; Fri, 08 May 2009 13:36:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.135.3 with SMTP id m3mr7331998ybn.55.1241815001084; Fri, 08 May 2009 13:36:41 -0700 (PDT) In-Reply-To: References: <4A048F93.1000309@yahoo-inc.com> <4A0494A7.9040307@apache.org> From: Javier Vegas Date: Fri, 8 May 2009 13:36:21 -0700 Message-ID: Subject: Re: NodeChildrenChanged WatchedEvent To: zookeeper-user@hadoop.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Maybe the name I selected is confusing, watchForChildrenChanges() is more descriptive than watchChildren(). The first indicates that I am setting a watch for children changes, the old name kinds of implies I am watching for changes on the children of the node, which is not what I want. Javier On Fri, May 8, 2009 at 1:31 PM, Javier Vegas wrote: > Sorry, what I meant is issuing the new method watchChildren() on the > parent node (basically the same as getChildren() but returning just a > boolean instead of a list of children, because I already know the > paths of the original children and the ones that were added/deleted so > I dont need the list again). I wasnt thinking (yet) about > grandchildren, but If I want to watch for them, I will need to do a > initial getChildren() on the new child that NodeChildrenChanged told > me about, followed by a watchChildren() after each event. Does this > make sense? > > Javier > > On Fri, May 8, 2009 at 1:23 PM, Patrick Hunt wrote: >> Javier, also note that the subsequent getChildren you mention in your >> original email is usually not entirely superfluous given that you generally >> want to watch the parent node for further changes, and a getChildren is >> required to set that watch. >> >> Patrick >> >> Benjamin Reed wrote: >>> >>> i'm adding a faq on this right now. it's a rather common request. >>> >>> we could put in the name of the node that is changing. indeed, we did in >>> the first cut of zookeeper, but then we found that every instance of >>> programs that used this resulted in bugs, so we removed it. >>> >>> here is the problem: >>> >>> you do a getChildren(), an event comes in that "foo" is deleted, and right >>> afterwords "goo" gets deleted, but you aren't going to get that event since >>> the previous delete fired and you haven't done another getChildren(). this >>> almost always results in an error, so much so that we don't even give people >>> the rope. >>> >>> ben >>> >>> Javier Vegas wrote: >>>> >>>> Hi, I am starting to implement Zookeeper as an arbiter for a high >>>> performance client-server service, it is working really well but I >>>> have a question. When my Watcher receives an event of >>>> NodeChildrenChanged event, is there any way of getting from the event >>>> the path for the child that changed? The WatchedEvent javadoc says >>>> that it "includes exactly what happened" but all I am able to extract >>>> is a vague "NodeChildrenChanged" type. What I am doing now to figure >>>> out the path of teh new child is to do a new getChildren and compare >>>> the new children list with the old children list, but that seems a >>>> waste of time and bandwith if my node has lots of children and is >>>> watched by a loot of zookeepers (which will be in prod). If I can >>>> somehow get the path of the added/deleted child from the >>>> WatchedEvent, it will make my life easier and my Zookeeper-powered >>>> system much more simple, robust and scalable. Any suggestions? >>>> >>>> Thanks, >>>> >>>> Javier Vegas >>>> >>> >> >