org.apache.hadoop.hbase
Interface InterProcessLock

All Known Implementing Classes:
ZKInterProcessLockBase, ZKInterProcessReadLock, ZKInterProcessWriteLock

@InterfaceAudience.Private
public interface InterProcessLock

An interface for an application-specific lock.


Nested Class Summary
static interface InterProcessLock.MetadataHandler
          An interface for objects that process lock metadata.
 
Method Summary
 void acquire()
          Acquire the lock, waiting indefinitely until the lock is released or the thread is interrupted.
 void reapAllLocks()
          If supported, attempts to reap all the locks of this type by forcefully deleting the locks (both held and attempted).
 void reapExpiredLocks(long expireTimeoutMs)
          If supported, attempts to reap all the locks of this type by forcefully deleting the locks (both held and attempted) that have expired according to the given timeout.
 void release()
          Release the lock.
 boolean tryAcquire(long timeoutMs)
          Acquire the lock within a wait time.
 void visitLocks(InterProcessLock.MetadataHandler handler)
          Visits the locks (both held and attempted) of this type with the given InterProcessLock.MetadataHandler.
 

Method Detail

acquire

void acquire()
             throws IOException,
                    InterruptedException
Acquire the lock, waiting indefinitely until the lock is released or the thread is interrupted.

Throws:
IOException - If there is an unrecoverable error releasing the lock
InterruptedException - If current thread is interrupted while waiting for the lock

tryAcquire

boolean tryAcquire(long timeoutMs)
                   throws IOException,
                          InterruptedException
Acquire the lock within a wait time.

Parameters:
timeoutMs - The maximum time (in milliseconds) to wait for the lock, -1 to wait indefinitely
Returns:
True if the lock was acquired, false if waiting time elapsed before the lock was acquired
Throws:
IOException - If there is an unrecoverable error talking talking (e.g., when talking to a lock service) when acquiring the lock
InterruptedException - If the thread is interrupted while waiting to acquire the lock

release

void release()
             throws IOException,
                    InterruptedException
Release the lock.

Throws:
IOException - If there is an unrecoverable error releasing the lock
InterruptedException - If the thread is interrupted while releasing the lock

reapExpiredLocks

void reapExpiredLocks(long expireTimeoutMs)
                      throws IOException
If supported, attempts to reap all the locks of this type by forcefully deleting the locks (both held and attempted) that have expired according to the given timeout. Lock reaping is different than coordinated lock revocation in that, there is no coordination, and the behavior is undefined if the lock holder is still alive.

Throws:
IOException - If there is an unrecoverable error reaping the locks

reapAllLocks

void reapAllLocks()
                  throws IOException
If supported, attempts to reap all the locks of this type by forcefully deleting the locks (both held and attempted). Lock reaping is different than coordinated lock revocation in that, there is no coordination, and the behavior is undefined if the lock holder is still alive. Calling this should have the same affect as calling reapExpiredLocks(long) with timeout=0.

Throws:
IOException - If there is an unrecoverable error reaping the locks

visitLocks

void visitLocks(InterProcessLock.MetadataHandler handler)
                throws IOException
Visits the locks (both held and attempted) of this type with the given InterProcessLock.MetadataHandler.

Throws:
InterruptedException - If there is an unrecoverable error
IOException


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.