curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kulkarni.swarnim@gmail.com" <kulkarni.swar...@gmail.com>
Subject Handling failure to acquire lock
Date Thu, 18 Jul 2013 01:20:27 GMT
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

Mime
View raw message