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 3BF239656 for ; Fri, 18 May 2012 17:55:47 +0000 (UTC) Received: (qmail 53370 invoked by uid 500); 18 May 2012 17:55:46 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 53298 invoked by uid 500); 18 May 2012 17:55:46 -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 53288 invoked by uid 99); 18 May 2012 17:55:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 May 2012 17:55:46 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.216.42] (HELO mail-qa0-f42.google.com) (209.85.216.42) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 May 2012 17:55:37 +0000 Received: by qafi31 with SMTP id i31so353900qaf.15 for ; Fri, 18 May 2012 10:55:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=k4PVzatMgLo21sFGc9Z9ocZsRPQ4zymxMUCHRADQ8yk=; b=Fae9cU1LsjN8z8CPmsoX36jY7MS94lqv5m6b0n6ritUg5QBZ+Vp24+3vLSFWoPartY VtUkkzwSEldjnmK2LYHH+aVzSYLAc0ZaXsVKoXwslY+wS4pMwsR1QaBOKZ59N5lvtCp2 qXsTeAtmMC8UzqUm5vNhEajXEzy+nv9pdflvNQBbEoSuHplPiYfTCVYuw3664buprHul fG6jlAGttvrJ1bxpYWjwfMk5FRfskBC4GrWpN9JpptQUYkYesbHGXTB5Qd2a8OLFDZYv jBH6kKc4sgmZvkG/Nt4w/pmDlHioISt7/bo3Dc2Ukah/bTLdwWeojsaJiqoYuFtnY5Q7 1Esg== Received: by 10.229.136.202 with SMTP id s10mr5963401qct.64.1337363716310; Fri, 18 May 2012 10:55:16 -0700 (PDT) Received: from [172.16.10.134] (75-144-176-10-NewEngland.hfc.comcastbusiness.net. [75.144.176.10]) by mx.google.com with ESMTPS id gb7sm22199220qab.12.2012.05.18.10.55.14 (version=SSLv3 cipher=OTHER); Fri, 18 May 2012 10:55:15 -0700 (PDT) Message-ID: <4FB68CFA.9080703@cabotresearch.com> Date: Fri, 18 May 2012 13:55:06 -0400 From: Joe Gamache User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: user@zookeeper.apache.org Subject: Re: Multi question on using previous ops results References: <4FB3CED2.3040606@cabotresearch.com> <9C90A51C-8263-499B-932C-4EAC528584AA@gmail.com> <4FB44112.9090407@cabotresearch.com> <4FB66E0A.7060804@cabotresearch.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQmElVA2hixIXJHEdHbcWl4x7RBTF8nVKdHyFvDr8pUvPekawyLOk29/RNSMd5To3C8t8JA5 Can you say again on a higher level what you really want to do? Hmmm. Probably not, but I will still try :) I have a one process that is trying to create some "work" that will be represented via a ZNode. A large number of other processes are looking for work. The node that represents the work will be sequential. Most importantly, it will be incomplete until the structure below it is completed. Thus, I would like to be able to create that node and lock it atomically OR create the entire structure below it atomically. I would like to avoid hacking in another parallel node structure solely for the purpose of locking (as there will be many 1000's of these created) All I am really wondering is can Zookeeper do this? If not, I can find alternate ways around - they just seem less elegant to me. On 5/18/2012 12:46 PM, Ted Dunning wrote: > No. It still isn't clear what benefit is of putting the version number of > one field into another. > > You seem to be focussing in on the minutiae of your proposed method rather > than on the goal that you really want to solve. > > A problem that seems similar to what you want is to form a graph where A > refers to B refers to C refers to A. The desired option would be update > the graph atomically so that B now points to D which points to A. The > intended use of multi here would be to do the standard read-modify-write > sort of cycle where you read the contents and versions of the items to be > updated or referenced in one operation and then in the next you do an > update which is conditioned on version with items which must remain static > having a version check. You repeat this cycle as many times as it takes, > presumably backing off between attempts. > > This has a theoretical possibility of fast updaters starving slow updaters > but this has never even been a possibility in any system I have seen, > largely because update rates are typically pretty low. > > Can you say again on a higher level what you really want to do? > > On Fri, May 18, 2012 at 11:43 AM, Joe Gamachewrote: > >> ... >> Ideally, I would like to be able to replace the "0" in various "setData" >> calls, not sure how to do that exactly, but the above would be a decent >> start. [If a node already existed and I was calling the Op.setData method >> and wanted to follow that with a Op.check call, I believe that I currently >> have no way of knowing the version number....] >> >> Does this make more sense than the gibberish I was trying below? >> >> thanks, >> >> Joe >> >> >> >> On 5/16/2012 8:06 PM, Joe Gamache wrote: >> >>> No thought about two znodes being synchronized at all. >>> >>> The higher level intent of the first (code) example is: how do you get >>> the version number for a set operation and use that value in the set >>> atomically? For the second one it is: how to I create and lock a znode >>> atomically? [maybe the Lock znode is attached to the node I am creating, >>> maybe in another structure? I don't really care, just can I do it >>> atomically?] >>> >>> Another way to do what I would like would be to create a znode structure >>> that is not "attached" to the existing one at all, then once I have it the >>> way it should be, attach it to an existing node. However, I am quite >>> certain this is not possible.... >>> >>> >>> >>> On 5/16/2012 7:21 PM, Ted Dunning wrote: >>> >>>> It looks like you are assuming that the versions of two znodes are >>>> synchronized. That seems pretty dangerous. >>>> >>>> What is the higher level intent here? Would it better to simply build a >>>> multi to update both znodes? >>>> >>>> Sent from my iPhone >>>> >>>> On May 16, 2012, at 11:59 AM, Joe Gamache> >>>> wrote: >>>> >>>> I need to do something like the following: >>>>> Stat stats = nodeToSet.getStat(); >>>>> if (stats != null) { >>>>> int version = stats.getVersion(); >>>>> stats = client.getZk().setData(path, data, version); >>>>> >>>>> (data was preset in code not shown). Since I have multiple processes >>>>> all vying to do things, in the worst case (which happens too frequently), >>>>> two processes execute the above at basically the same time, which causes >>>>> errors. I thought I might be able to use Multi to do this atomically, but >>>>> I cannot figure out how to use the result (the version number above) from >>>>> one Op in a later Op. Is this possible? >>>>> >>>>> This was the simplest example I could find, but this happens often - >>>>> usually with Paths. For instance, sometimes I create a zookeeper node and >>>>> want a "LOCK" node underneath it. If I follow the "recipe" and use an >>>>> ephemeral sequential node as the lock, how can I refer to sequence in a >>>>> Path in subsequent Op added to a "multi" or is there any way to do it >>>>> atomically? Sorry that was so very wordy. What I was really trying to >>>>> ask, is how do I create and lock a node atomically? >>>>> >>>>> thanks for any help, insight! >>>>> >>>>> joe >>>>> >>>>>