Return-Path: X-Original-To: apmail-curator-user-archive@minotaur.apache.org Delivered-To: apmail-curator-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6DE6510BA8 for ; Thu, 18 Jul 2013 01:21:13 +0000 (UTC) Received: (qmail 11241 invoked by uid 500); 18 Jul 2013 01:21:13 -0000 Delivered-To: apmail-curator-user-archive@curator.apache.org Received: (qmail 11210 invoked by uid 500); 18 Jul 2013 01:21:13 -0000 Mailing-List: contact user-help@curator.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@curator.incubator.apache.org Delivered-To: mailing list user@curator.incubator.apache.org Received: (qmail 11202 invoked by uid 99); 18 Jul 2013 01:21:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jul 2013 01:21:13 +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 (athena.apache.org: domain of kulkarni.swarnim@gmail.com designates 209.85.219.44 as permitted sender) Received: from [209.85.219.44] (HELO mail-oa0-f44.google.com) (209.85.219.44) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jul 2013 01:21:08 +0000 Received: by mail-oa0-f44.google.com with SMTP id l10so3447786oag.17 for ; Wed, 17 Jul 2013 18:20:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=8PH/w+QUYbMcFMalYoy6+WZAz1Kx4Z982sq+HvtHcfA=; b=J6ym9913MoKjrudzyr74Gp7pfWrba65c6bSOPzRmuUi04Dvfm7JNysJh/L+VgX5m0u 851atAmpBPYiy2xrc+SVzdxR4r2sEMqPX1xE605/faArIdCdsniBcPFM44PbJmUgrcMH ryVvzjKrr8lpOTvN0GFEwQEDXgbQ9RFHSdq541kacHejS3vyufbMCiabvdUGbCi8yGbK 7FqHih+bVQQvUADXqL3h49x7cJsmeaP+5aWbyYEmHqiikNBnlnQpGslTxvnzDsQygqTv bGJ0nqgPrg6BPBzw0cmIjqybMoryMdgGcMB7nnDPRQYTWaEDfW/WOlRXNasW8AQ71Z0Y SqzQ== X-Received: by 10.60.94.136 with SMTP id dc8mr10857273oeb.89.1374110447655; Wed, 17 Jul 2013 18:20:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.160.106 with HTTP; Wed, 17 Jul 2013 18:20:27 -0700 (PDT) From: "kulkarni.swarnim@gmail.com" Date: Wed, 17 Jul 2013 20:20:27 -0500 Message-ID: Subject: Handling failure to acquire lock To: user@curator.incubator.apache.org Content-Type: multipart/alternative; boundary=089e0116026a1d646a04e1bf059b X-Virus-Checked: Checked by ClamAV on apache.org --089e0116026a1d646a04e1bf059b Content-Type: text/plain; charset=ISO-8859-1 Hello, I am trying to use the InterProcessMutex to lock a shared resource on HDFS. My question is how are we supposed to handle cases where a client fails to acquire the mutex lock? I am using the method here[1] to acquire the lock. The javadoc states that an "Exception" is thrown if there were ZK errors or interruptions while attempting to acquire the lock. I am assuming this includes some recoverable exceptions as well. Is it wise to wrap this up in a RetryLoop? Something like: RetryLoop retryLoop = client.newRetryLoop(); while ( retryLoop.shouldContinue() ) { try { lock.acquireLock(); // attempt to acquire the lock } catch ( Exception e ) { retryLoop.takeException(e); } } Thanks, [1] http://curator.incubator.apache.org/apidocs/org/apache/curator/framework/recipes/locks/InterProcessMutex.html#acquire(long, java.util.concurrent.TimeUnit) -- Swarnim --089e0116026a1d646a04e1bf059b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello,

I am trying to use the InterProc= essMutex to lock a shared resource on HDFS. My question is how are we suppo= sed to handle cases where a client fails to acquire the mutex lock?

I am using the method here[1] to acquire the lock. The javad= oc states that an "Exception" is thrown if there were ZK errors o= r interruptions while attempting to acquire the lock. I am assuming this in= cludes some recoverable exceptions as well.

Is it wise to wrap this up in a RetryLoop? Something li= ke:

RetryLoop retryLoop =3D client.newRetryLoop();
 while ( retryLoop.shouldContinue() )
 {
     try
     {
         lock.acquireLock(); // attempt to acquire the lock
     }
     catch ( Exception e )
     {
         retryLoop.takeException(e);
     }
 }

Thanks,

[1]=A0http://curator.in= cubator.apache.org/apidocs/org/apache/curator/framework/recipes/locks/Inter= ProcessMutex.html#acquire(long, java.util.concurrent.TimeUnit)

--
Swarnim
--089e0116026a1d646a04e1bf059b--