org.apache.accumulo.core.zookeeper
Class ZooLock
java.lang.Object
org.apache.accumulo.core.zookeeper.ZooLock
- All Implemented Interfaces:
- org.apache.zookeeper.Watcher
public class ZooLock
- extends java.lang.Object
- implements org.apache.zookeeper.Watcher
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher |
org.apache.zookeeper.Watcher.Event |
Constructor Summary |
ZooLock(java.lang.String path)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOCK_PREFIX
public static final java.lang.String LOCK_PREFIX
- See Also:
- Constant Field Values
ZooLock
public ZooLock(java.lang.String path)
tryLock
public boolean tryLock(ZooLock.LockWatcher lw,
byte[] data)
throws org.apache.zookeeper.KeeperException,
java.lang.InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
lockAsync
public void lockAsync(ZooLock.AsyncLockWatcher lw,
byte[] data)
tryToCancelAsyncLockOrUnlock
public boolean tryToCancelAsyncLockOrUnlock()
throws java.lang.InterruptedException,
org.apache.zookeeper.KeeperException
- Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException
unlock
public void unlock()
throws java.lang.InterruptedException,
org.apache.zookeeper.KeeperException
- Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException
getLockPath
public java.lang.String getLockPath()
getLockName
public java.lang.String getLockName()
getLockID
public ZooLock.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:
isLocked
public boolean isLocked()
process
public void process(org.apache.zookeeper.WatchedEvent event)
- Specified by:
process
in interface org.apache.zookeeper.Watcher
isLockHeld
public static boolean isLockHeld(org.apache.zookeeper.ZooKeeper zk,
ZooLock.LockID lid)
throws org.apache.zookeeper.KeeperException,
java.lang.InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
isLockHeld
public static boolean isLockHeld(ZooCache zc,
ZooLock.LockID lid)
getLockData
public static byte[] getLockData(org.apache.zookeeper.ZooKeeper zk,
java.lang.String path)
throws org.apache.zookeeper.KeeperException,
java.lang.InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
getLockData
public static byte[] getLockData(ZooCache zc,
java.lang.String path)
getLockData
public static byte[] getLockData(java.lang.String path)
getSessionId
public static long getSessionId(ZooCache zc,
java.lang.String path)
throws org.apache.zookeeper.KeeperException,
java.lang.InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
getSessionId
public long getSessionId()
throws org.apache.zookeeper.KeeperException,
java.lang.InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
java.lang.InterruptedException
deleteLock
public static void deleteLock(java.lang.String path)
throws java.lang.InterruptedException,
org.apache.zookeeper.KeeperException
- Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException
deleteLock
public static boolean deleteLock(java.lang.String path,
java.lang.String lockData)
throws java.lang.InterruptedException,
org.apache.zookeeper.KeeperException
- Throws:
java.lang.InterruptedException
org.apache.zookeeper.KeeperException
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- Throws:
java.lang.Exception
Copyright © 2012 The Apache Software Foundation. All Rights Reserved.