Class ZooLock
- java.lang.Object
-
- org.apache.accumulo.fate.zookeeper.ZooLock
-
- All Implemented Interfaces:
org.apache.zookeeper.Watcher
public class ZooLock extends Object implements org.apache.zookeeper.Watcher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceZooLock.AsyncLockWatcherstatic classZooLock.LockLossReasonstatic interfaceZooLock.LockWatcher
-
Field Summary
Fields Modifier and Type Field Description static StringLOCK_PREFIXprotected ZooReaderWriterzooKeeper
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voiddeleteLock(ZooReaderWriter zk, String path)static booleandeleteLock(ZooReaderWriter zk, String path, String lockData)static byte[]getLockData(ZooCache zc, String path, ZooCache.ZcStat stat)static byte[]getLockData(org.apache.zookeeper.ZooKeeper zk, String path)ZooUtil.LockIDgetLockID()StringgetLockName()StringgetLockPath()longgetSessionId()static longgetSessionId(ZooCache zc, String path)booleanisLocked()static booleanisLockHeld(ZooCache zc, ZooUtil.LockID lid)voidlockAsync(ZooLock.AsyncLockWatcher lw, byte[] data)voidprocess(org.apache.zookeeper.WatchedEvent event)voidreplaceLockData(byte[] b)booleantryLock(ZooLock.LockWatcher lw, byte[] data)booleantryToCancelAsyncLockOrUnlock()voidunlock()booleanwasLockAcquired()indicates if the lock was acquired in the past....
-
-
-
Field Detail
-
LOCK_PREFIX
public static final String LOCK_PREFIX
- See Also:
- Constant Field Values
-
zooKeeper
protected final ZooReaderWriter zooKeeper
-
-
Constructor Detail
-
ZooLock
public ZooLock(ZooReaderWriter zoo, String path)
-
ZooLock
protected ZooLock(ZooCache zc, ZooReaderWriter zrw, String path)
-
-
Method Detail
-
tryLock
public boolean tryLock(ZooLock.LockWatcher lw, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
lockAsync
public void lockAsync(ZooLock.AsyncLockWatcher lw, byte[] data)
-
tryToCancelAsyncLockOrUnlock
public boolean tryToCancelAsyncLockOrUnlock() throws InterruptedException, org.apache.zookeeper.KeeperException- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
unlock
public void unlock() throws InterruptedException, org.apache.zookeeper.KeeperException- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
getLockPath
public String getLockPath()
-
getLockName
public String getLockName()
-
getLockID
public ZooUtil.LockID getLockID()
-
wasLockAcquired
public boolean wasLockAcquired()
indicates if the lock was acquired in the past.... helps discriminate between the case where the lock was never held, or held and lost....- Returns:
- true if the lock was acquired, otherwise false.
-
isLocked
public boolean isLocked()
-
replaceLockData
public void replaceLockData(byte[] b) throws org.apache.zookeeper.KeeperException, InterruptedException- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
process
public void process(org.apache.zookeeper.WatchedEvent event)
- Specified by:
processin interfaceorg.apache.zookeeper.Watcher
-
isLockHeld
public static boolean isLockHeld(ZooCache zc, ZooUtil.LockID lid)
-
getLockData
public static byte[] getLockData(org.apache.zookeeper.ZooKeeper zk, String path) throws org.apache.zookeeper.KeeperException, InterruptedException- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
getLockData
public static byte[] getLockData(ZooCache zc, String path, ZooCache.ZcStat stat)
-
getSessionId
public long getSessionId() throws org.apache.zookeeper.KeeperException, InterruptedException- Throws:
org.apache.zookeeper.KeeperExceptionInterruptedException
-
deleteLock
public static void deleteLock(ZooReaderWriter zk, String path) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
deleteLock
public static boolean deleteLock(ZooReaderWriter zk, String path, String lockData) throws InterruptedException, org.apache.zookeeper.KeeperException
- Throws:
InterruptedExceptionorg.apache.zookeeper.KeeperException
-
-