Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2BB7D913F for ; Thu, 1 Mar 2012 23:28:53 +0000 (UTC) Received: (qmail 10519 invoked by uid 500); 1 Mar 2012 23:28:52 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 10496 invoked by uid 500); 1 Mar 2012 23:28:52 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 10470 invoked by uid 99); 1 Mar 2012 23:28:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Mar 2012 23:28:52 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of marshall.mcmullen@gmail.com designates 209.85.212.170 as permitted sender) Received: from [209.85.212.170] (HELO mail-wi0-f170.google.com) (209.85.212.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Mar 2012 23:28:42 +0000 Received: by mail-wi0-f170.google.com with SMTP id hj13so325680wib.15 for ; Thu, 01 Mar 2012 15:28:22 -0800 (PST) Received: by 10.180.78.130 with SMTP id b2mr5560513wix.1.1330644502608; Thu, 01 Mar 2012 15:28:22 -0800 (PST) Received: from mail-bk0-f42.google.com (mail-bk0-f42.google.com [209.85.214.42]) by mx.google.com with ESMTPS id bg3sm44893676wib.10.2012.03.01.15.28.21 (version=SSLv3 cipher=OTHER); Thu, 01 Mar 2012 15:28:21 -0800 (PST) Received: by bkcje9 with SMTP id je9so1099153bkc.15 for ; Thu, 01 Mar 2012 15:28:20 -0800 (PST) Received-SPF: pass (google.com: domain of marshall.mcmullen@gmail.com designates 10.204.156.129 as permitted sender) client-ip=10.204.156.129; Received: from mr.google.com ([10.204.156.129]) by 10.204.156.129 with SMTP id x1mr3849560bkw.72.1330644500752 (num_hops = 1); Thu, 01 Mar 2012 15:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=pfdkf5BUhxgBzLd6rOAcRjm9whifCjFzfEFDekM50V0=; b=OSzmU8mhchrzyS/H411Tfth/qyZrUxE4e+RExoz5b7EfvsEbIhpokaXTRt8it+xjBz 0JFuYDjehXFPvgw2TASYdxTfx3W8HODldDo7dMX+mBK6cPeokWjEgzt0J/EHZaXgLgnS w9rpFB1+g32DvuF08APcSnIVnj6LgtNDbCIb72aVd4xb7NChTexr79CD7BUkJMS6rPm3 iA722b0rIhLxt/Q0ayq/XGQ8x84Jz4g3qL+VeK0vYuSfwsJ2hL3U7s/hGivG0vL0IXaA QIObwnKL46NKfRG0rXnXfoWbqqxgjii2Y399XkogwaqK6jScGC+lQ8PdhcpsC8ZMh2bS dR8A== MIME-Version: 1.0 Received: by 10.204.156.129 with SMTP id x1mr3077321bkw.72.1330644500717; Thu, 01 Mar 2012 15:28:20 -0800 (PST) Received: by 10.204.75.194 with HTTP; Thu, 1 Mar 2012 15:28:20 -0800 (PST) X-Originating-IP: [173.164.43.53] In-Reply-To: References: Date: Thu, 1 Mar 2012 23:28:20 +0000 Message-ID: Subject: Re: Create nested paths From: Marshall McMullen To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary=000e0ce0275ac9a21e04ba36d00c X-Gm-Message-State: ALoCoQlkyE6tx1s98IxuvdFP4bKM9Eq2Xn4d23IVfIgSZdKSF41j1L/a2qbJOd+1Rb2PJBQZgPZ+ X-Virus-Checked: Checked by ClamAV on apache.org --000e0ce0275ac9a21e04ba36d00c Content-Type: text/plain; charset=ISO-8859-1 Check is just handled the same as the other ops. In the PrepRequestProcessor stage if the requested path doesn't exist, then it aborts the multi with an error. On Thu, Mar 1, 2012 at 11:25 PM, Ted Dunning wrote: > Harrumph. > > The only good thing to say here is that, yes, there is a one to one > correspondence between arguments and results in the returned list. > > I will have to check the documentation to see if throwing an exception is > the correct thing to do for check. It surprises me a bit that you are > seeing this result. > > Sent from my iPhone > > On Mar 1, 2012, at 3:14 PM, "Shelley, Ryan" > wrote: > > > Right, I did this: > > > > (psuedo-code) > > List ops > > For(path in paths) > > ops.add( Op.check(path, -1) ) > > EndFor > > > > List Results = Zk.multi(ops) > > > > This causes an exception to be thrown on the first path that doesn't > > exist. It doesn't return back a list with one OpResult flagged with an > > error. I was under the impression I'd get back a bunch of OpResult > objects > > with flags of error, or otherwise, and then I could build another list of > > operations to create what's needed (which, even if it did work, the > > CheckResult object doesn't include the path, so I'm just hoping the > > results are in the same order as the operations were listed in, as I have > > to infer the path I'll need to build from the position of the OpResult in > > the list). > > > > > > > > On 3/1/12 3:05 PM, "Ted Dunning" wrote: > > > >> No. I meant one call full of checks and a second call with any necessary > >> creates. > >> > >> Sent from my iPhone > >> > >> On Mar 1, 2012, at 11:17 AM, "Shelley, Ryan" > >> wrote: > >> > >>> Ok, I tried this with the Op.create and found that it will throw a > >>> KeeperException on the first path that doesn't exist. It doesn't return > >>> back an OpResult with an "error" type. I can still use this, and just > >>> catch the exception and create the node in the exception, but I was > >>> under > >>> the impression that I could do this in two trips. One trip to get back > a > >>> list of OpResults from the check that would inform me if the path > >>> existed > >>> or not, and a second trip to create all the paths that don't exist (and > >>> as > >>> a note, the CheckResult object doesn't include the path, so I have to > >>> infer it from the order of my original list of paths used to create the > >>> multi-check). > >>> > >>> -Ryan > >>> > >>> On 2/29/12 7:16 PM, "Ted Dunning" wrote: > >>> > >>>> On Wed, Feb 29, 2012 at 7:04 PM, Marshall McMullen < > >>>> marshall.mcmullen@gmail.com> wrote: > >>>> > >>>>> Yes, Ted's right. The multi has to fail as that's part of the > contract > >>>>> it > >>>>> guarantees. > >>>>> > >>>>> The only thing you could do, which will significantly narrow the race > >>>>> condition, is as you're *building *the multi, check if the path > >>>>> already > >>>>> exists. If so, then don't add the create op for that path into the > >>>>> multi. > >>>>> Of course this may not work in every situation, but we use that > >>>>> approach in > >>>>> many code paths and it works well. > >>>>> > >>>> > >>>> Another approach is to compose one multi with Op.exists() for each > >>>> level > >>>> so > >>>> that you find everything you need, then create another with the > correct > >>>> Op.create() operations. That gets the problem down to two server > >>>> round-trips but still has the race condition. > >>> > > > --000e0ce0275ac9a21e04ba36d00c--