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 B3CEA9596 for ; Thu, 1 Mar 2012 23:26:11 +0000 (UTC) Received: (qmail 1082 invoked by uid 500); 1 Mar 2012 23:26:11 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 977 invoked by uid 500); 1 Mar 2012 23:26:11 -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 968 invoked by uid 99); 1 Mar 2012 23:26:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Mar 2012 23:26:11 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.210.42 as permitted sender) Received: from [209.85.210.42] (HELO mail-pz0-f42.google.com) (209.85.210.42) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Mar 2012 23:26:04 +0000 Received: by dang27 with SMTP id g27so1373017dan.15 for ; Thu, 01 Mar 2012 15:25:44 -0800 (PST) Received-SPF: pass (google.com: domain of ted.dunning@gmail.com designates 10.68.194.193 as permitted sender) client-ip=10.68.194.193; Authentication-Results: mr.google.com; spf=pass (google.com: domain of ted.dunning@gmail.com designates 10.68.194.193 as permitted sender) smtp.mail=ted.dunning@gmail.com; dkim=pass header.i=ted.dunning@gmail.com Received: from mr.google.com ([10.68.194.193]) by 10.68.194.193 with SMTP id hy1mr8630406pbc.53.1330644344446 (num_hops = 1); Thu, 01 Mar 2012 15:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=A/IOS8wKXlNgx6lAFzTXGzkDkjoOFV5jesr/AWaJtcY=; b=psiGBN7UWX0Hvn8ZW8LPkEcXL/0aghMFomVNfPqBwPKQNyTFDnDtm0gNjq+M/2sBIr /K59U7ZAQnTTM59/6/xWa+85av9jZITFyL1kyJ5gbZhpd7Y9q52HWNbm02bwTItH+Os8 9ZpYRUY631hJFDbvxUJR466SRt2eHGuvPdsst5Y9jTNRts04o/Pol263psxLwewvVXgj TxxdzTMxYHtUuatI3yvuoDlRkGcMf1B5YAFzr2R24JgFjtnekBt0VqGBr1gP3VxSnk6+ Y7bM5qFHui4mjBe2fJy5WhvaSEYpTdkENEz+jl+Ms3qn12puTylXJvr8GCTaE+NP8g63 fxSw== Received: by 10.68.194.193 with SMTP id hy1mr7110997pbc.53.1330644344183; Thu, 01 Mar 2012 15:25:44 -0800 (PST) Received: from [10.78.84.206] (mobile-166-205-138-149.mycingular.net. [166.205.138.149]) by mx.google.com with ESMTPS id q10sm3270887pbb.10.2012.03.01.15.25.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Mar 2012 15:25:43 -0800 (PST) References: In-Reply-To: Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: Cc: "user@zookeeper.apache.org" X-Mailer: iPhone Mail (9A406) From: Ted Dunning Subject: Re: Create nested paths Date: Thu, 1 Mar 2012 15:25:39 -0800 To: "user@zookeeper.apache.org" X-Virus-Checked: Checked by ClamAV on apache.org Harrumph.=20 The only good thing to say here is that, yes, there is a one to one correspo= ndence between arguments and results in the returned list.=20 I will have to check the documentation to see if throwing an exception is th= e correct thing to do for check. It surprises me a bit that you are seeing t= his result.=20 Sent from my iPhone On Mar 1, 2012, at 3:14 PM, "Shelley, Ryan" wrote:= > Right, I did this: >=20 > (psuedo-code) > List ops > For(path in paths) > ops.add( Op.check(path, -1) ) > EndFor >=20 > List Results =3D Zk.multi(ops) >=20 > 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). >=20 >=20 >=20 > On 3/1/12 3:05 PM, "Ted Dunning" wrote: >=20 >> No. I meant one call full of checks and a second call with any necessary >> creates.=20 >>=20 >> Sent from my iPhone >>=20 >> On Mar 1, 2012, at 11:17 AM, "Shelley, Ryan" >> wrote: >>=20 >>> 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). >>>=20 >>> -Ryan >>>=20 >>> On 2/29/12 7:16 PM, "Ted Dunning" wrote: >>>=20 >>>> On Wed, Feb 29, 2012 at 7:04 PM, Marshall McMullen < >>>> marshall.mcmullen@gmail.com> wrote: >>>>=20 >>>>> Yes, Ted's right. The multi has to fail as that's part of the contract= >>>>> it >>>>> guarantees. >>>>>=20 >>>>> 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. >>>>>=20 >>>>=20 >>>> 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. >>>=20 >=20