Return-Path: Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: (qmail 53960 invoked from network); 16 Dec 2010 19:25:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Dec 2010 19:25:51 -0000 Received: (qmail 87602 invoked by uid 500); 16 Dec 2010 19:25:51 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 87501 invoked by uid 500); 16 Dec 2010 19:25:50 -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 87493 invoked by uid 99); 16 Dec 2010 19:25:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Dec 2010 19:25:50 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.213.170 as permitted sender) Received: from [209.85.213.170] (HELO mail-yx0-f170.google.com) (209.85.213.170) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Dec 2010 19:25:44 +0000 Received: by yxi11 with SMTP id 11so2916309yxi.15 for ; Thu, 16 Dec 2010 11:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=DzMqyulsOI5g2GA5VBEl+tpypthpaTEpedxeYJn2gfE=; b=rrQtoIdiTal6HIw3il1dsszhtHG1CD2zh/TWdLtptCVlsxAlcI5TBSee/2eQ5f4mx8 ju0SzyyMstmJE1bz0T5rkyyQdjnkhhMP6PGQ6iI041aLFzYnL1c346ry8UwnQM41CJPO EJ8Ja5kyXSeTTELozg1ekPStgcgdZV6zeuRsQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=xHs2rBPzQ31/WoCTg/ZtuFfziPCgObCx7FCMO7by6MTMZVlcKgrx7JfYQKtfHWDrxf cpxsd0QqnvHBRyd0eQEUxKF9fiqSCGPuYFiQvY2KMGgXB2Wd5RzDD2bOYeS3Uj9hlrFE ft6lDkzSqxEjfnCF+ZN9xv478ufN/ec80+k2M= Received: by 10.236.110.6 with SMTP id t6mr5173670yhg.17.1292527523715; Thu, 16 Dec 2010 11:25:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.103.17 with HTTP; Thu, 16 Dec 2010 11:25:03 -0800 (PST) In-Reply-To: References: From: Ted Dunning Date: Thu, 16 Dec 2010 11:25:03 -0800 Message-ID: Subject: Re: need for more conditional write support To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary=0023547c9015e9eb8d04978c0364 --0023547c9015e9eb8d04978c0364 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable One alternative is to simply specify -1 in the version list to avoid the version check for that one item. That would allow the subset constraint to be retained as a valid semantic check for most situations and would allow a very explicit way to describe when you want to violate that constraint. On Thu, Dec 16, 2010 at 10:06 AM, Dave Wright wrote: > I'm not sure why (other than your syntax) you would require the second > list (to update) to be a subset of the first (to test). There are > plenty of situations where you may want to update one node based on > the value of another (and test that the value hasn't changed before > updating) but don't really care about the second node, and it would > just be extra overhead to check it's current value. In fact, I think > that was the OP's situation. > > -Dave > > On Thu, Dec 16, 2010 at 1:01 PM, Ted Dunning > wrote: > > Yes. This is isomorphic to my suggestion to allow null data. We shoul= d > > toss around many options to figure out which is the most congenial idio= m. > > Yours is nice since it has two sets of parallel lists. > > > > In java with optional arguments it would be possible to use a builder > style > > with optional arguments: > > > > zk.testVersions(node1, version1, node2, version2, ...) > > .updateData(node1, data1, node3, data3, ...) > > > > I would tend to make it part of the contract that the nodes in the seco= nd > > part be a subset of of the nodes in the first part. The first method > would > > create an object packaging up the first set of args and the second meth= od > > would do the work. Of course, this is just syntactic sugar for the mor= e > > list oriented version. > > > > On Thu, Dec 16, 2010 at 8:16 AM, Dave Wright wrote: > > > >> My recommendation would actually be a combination of the two which > >> offers the most flexibility: > >> > >> zoo_multi_test_and_set(List znodesToTest, List versions, > >> List znodesToSet, List data=EF=BC=89 > >> > >> ...this specifies a list of nodes & versions to check, and if the > >> versions match, a list of nodes to set and the associated data. > >> This allows multiple scenarios, including setting nodes other than the > >> ones you are version checking, setting more nodes than you version > >> check, checking more nodes than you set, etc. > >> I don't think the implementation would be any harder than either of th= e > >> others. > >> > >> -Dave > >> > >> > >> On Wed, Dec 15, 2010 at 10:50 AM, Ted Dunning > >> wrote: > >> > Well, I would just call the first method set. > >> > > >> > And I think that the second method is no easier to implement and > probably > >> a > >> > bit less useful. > >> > > >> > The idea that the second might be almost as useful as the first is > >> > interesting however. It probably > >> > means that we should allow some of the data elements to be null or > >> something > >> > to allow for testing > >> > versions but not setting data. > >> > > >> > On Tue, Dec 14, 2010 at 11:21 PM, Qian Ye > wrote: > >> > > >> >> zoo_multi_test_and_set(List versions, List znodes, > >> >> List data=EF=BC=89 > >> >> > >> >> can solve the problem I mentioned before, and some relavant issues, > like > >> >> hard for programmers to use, as mentioned in mail-archive, should b= e > >> paid > >> >> attention to. I think we can move small step first, that is, provid= e > >> >> interface like > >> >> > >> >> zoo_multi_test_and_set(List versions, List znodes, > byte[] > >> >> data, string znode=EF=BC=89 > >> >> > >> >> > >> >> The API test versions of several different znodes before set one > znode, > >> and > >> >> if the client want to set other znode, it can call this API > repeatedly. > >> >> Because we only set one node by this API, the result will be > straight, > >> >> success or failure. We need not take care of the half-success resul= t. > >> >> > >> >> How do ur guys think about this API? > >> >> > >> > > >> > > > --0023547c9015e9eb8d04978c0364--