public class ZooLock extends Object implements org.apache.zookeeper.Watcher
Modifier and Type | Class and Description |
---|---|
static interface |
ZooLock.AsyncLockWatcher |
static class |
ZooLock.LockLossReason |
static interface |
ZooLock.LockWatcher |
Modifier and Type | Field and Description |
---|---|
static String |
LOCK_PREFIX |
protected IZooReaderWriter |
zooKeeper |
Modifier | Constructor and Description |
---|---|
|
ZooLock(String zookeepers,
int timeInMillis,
String scheme,
byte[] auth,
String path) |
protected |
ZooLock(ZooCache zc,
IZooReaderWriter zrw,
String path) |
|
ZooLock(ZooReaderWriter zoo,
String path) |
Modifier and Type | Method and Description |
---|---|
static void |
deleteLock(IZooReaderWriter zk,
String path) |
static boolean |
deleteLock(IZooReaderWriter 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.LockID |
getLockID() |
String |
getLockName() |
String |
getLockPath() |
long |
getSessionId() |
static long |
getSessionId(ZooCache zc,
String path) |
boolean |
isLocked() |
static boolean |
isLockHeld(ZooCache zc,
ZooUtil.LockID lid) |
void |
lockAsync(ZooLock.AsyncLockWatcher lw,
byte[] data) |
void |
process(org.apache.zookeeper.WatchedEvent event) |
void |
replaceLockData(byte[] b) |
boolean |
tryLock(ZooLock.LockWatcher lw,
byte[] data) |
boolean |
tryToCancelAsyncLockOrUnlock() |
void |
unlock() |
boolean |
wasLockAcquired()
indicates if the lock was acquired in the past....
|
public static final String LOCK_PREFIX
protected final IZooReaderWriter zooKeeper
public ZooLock(ZooReaderWriter zoo, String path)
public ZooLock(String zookeepers, int timeInMillis, String scheme, byte[] auth, String path)
protected ZooLock(ZooCache zc, IZooReaderWriter zrw, String path)
public boolean tryLock(ZooLock.LockWatcher lw, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void lockAsync(ZooLock.AsyncLockWatcher lw, byte[] data)
public boolean tryToCancelAsyncLockOrUnlock() throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
public void unlock() throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
public String getLockPath()
public String getLockName()
public ZooUtil.LockID getLockID()
public boolean wasLockAcquired()
public boolean isLocked()
public void replaceLockData(byte[] b) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public void process(org.apache.zookeeper.WatchedEvent event)
process
in interface org.apache.zookeeper.Watcher
public static boolean isLockHeld(ZooCache zc, ZooUtil.LockID lid)
public static byte[] getLockData(org.apache.zookeeper.ZooKeeper zk, String path) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public static byte[] getLockData(ZooCache zc, String path, ZooCache.ZcStat stat)
public long getSessionId() throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperException
InterruptedException
public static void deleteLock(IZooReaderWriter zk, String path) throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
public static boolean deleteLock(IZooReaderWriter zk, String path, String lockData) throws InterruptedException, org.apache.zookeeper.KeeperException
InterruptedException
org.apache.zookeeper.KeeperException
Copyright © 2011–2019 The Apache Software Foundation. All rights reserved.