Return-Path: Delivered-To: apmail-hadoop-zookeeper-user-archive@minotaur.apache.org Received: (qmail 95664 invoked from network); 23 Feb 2010 18:28:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Feb 2010 18:28:25 -0000 Received: (qmail 65125 invoked by uid 500); 23 Feb 2010 18:28:25 -0000 Delivered-To: apmail-hadoop-zookeeper-user-archive@hadoop.apache.org Received: (qmail 65091 invoked by uid 500); 23 Feb 2010 18:28:25 -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 65081 invoked by uid 99); 23 Feb 2010 18:28:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Feb 2010 18:28:25 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ted.dunning@gmail.com designates 209.85.160.48 as permitted sender) Received: from [209.85.160.48] (HELO mail-pw0-f48.google.com) (209.85.160.48) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Feb 2010 18:28:17 +0000 Received: by pwi6 with SMTP id 6so3640738pwi.35 for ; Tue, 23 Feb 2010 10:27:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=uuQpu9+HQtd5E50mErtTEaOwFAihjPln05pGfjsv9WM=; b=l09H1ZuSDIKuCpuieHusxyts15UOE1wAIDORiOxwrAnKudxXUAxqqZhXkNTk70u6bt Ti38aUUvV5YKE1Qcfg2VHyXRQ/le/M3jK6fjc10DuD8pl/r2LjRDsT75efPGmoGwiJGK rTvaiKAIPv/lOPbeGOWu2z3bJhNK+PbFIM2os= 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=SKfCCkeT4ZYe4hCAosJ1o3z0HhhCBUFK43hDzw7NW3z2c+haz/Un1VQW+ajH0ZgOUS 9DvI/X5f/nrQFSUXm7Hi0WVE4+NSFlFp1SREVkvfXNoZHhY7N7EQUgy/9VSlg/l98ES+ rxYc5pYcTqjMjENpEKuyJGdRSSajyqQAopSyI= MIME-Version: 1.0 Received: by 10.141.188.32 with SMTP id q32mr1063188rvp.183.1266949675150; Tue, 23 Feb 2010 10:27:55 -0800 (PST) In-Reply-To: <8bc75ecf1002230405u4f28a5f4q4a25348b35af3671@mail.gmail.com> References: <8bc75ecf1002230405u4f28a5f4q4a25348b35af3671@mail.gmail.com> From: Ted Dunning Date: Tue, 23 Feb 2010 10:27:35 -0800 Message-ID: Subject: Re: how to lock one-of-many ? To: zookeeper-user@hadoop.apache.org Content-Type: multipart/alternative; boundary=000e0cd17e2255edb4048048b534 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd17e2255edb4048048b534 Content-Type: text/plain; charset=UTF-8 I think that the crux of Mahadev's suggestion is that you do as you say, but you should try the resources in randomized order. That will have very robust properties, especially with more than a handful of resources and is easy to code and to analyze. It won't work if you really mean "lock first available from this sequence". On Tue, Feb 23, 2010 at 4:05 AM, Martin Waite wrote: > For locking, I could loop through > the available ids, attempting to create a lock for that in the locked > directory. However this seems a bit clumsy and slow. Also, the locks are > held for a relatively short time (1 second on average), and by time I have > blundered through all the possible locks, ids that were locked at the start > might be available by time I finished. > -- Ted Dunning, CTO DeepDyve --000e0cd17e2255edb4048048b534--