org.apache.accumulo.core.zookeeper
Class ZooLock

java.lang.Object
  extended by 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 Class Summary
static interface ZooLock.AsyncLockWatcher
           
static class ZooLock.LockID
           
static class ZooLock.LockLossReason
           
static interface ZooLock.LockWatcher
           
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event
 
Field Summary
static java.lang.String LOCK_PREFIX
           
 
Constructor Summary
ZooLock(java.lang.String path)
           
 
Method Summary
static void deleteLock(java.lang.String path)
           
static boolean deleteLock(java.lang.String path, java.lang.String lockData)
           
static byte[] getLockData(java.lang.String path)
           
static byte[] getLockData(ZooCache zc, java.lang.String path)
           
static byte[] getLockData(org.apache.zookeeper.ZooKeeper zk, java.lang.String path)
           
 ZooLock.LockID getLockID()
           
 java.lang.String getLockName()
           
 java.lang.String getLockPath()
           
 long getSessionId()
           
static long getSessionId(ZooCache zc, java.lang.String path)
           
 boolean isLocked()
           
static boolean isLockHeld(ZooCache zc, ZooLock.LockID lid)
           
static boolean isLockHeld(org.apache.zookeeper.ZooKeeper zk, ZooLock.LockID lid)
           
 void lockAsync(ZooLock.AsyncLockWatcher lw, byte[] data)
           
static void main(java.lang.String[] args)
           
 void process(org.apache.zookeeper.WatchedEvent event)
           
 boolean tryLock(ZooLock.LockWatcher lw, byte[] data)
           
 boolean tryToCancelAsyncLockOrUnlock()
           
 void unlock()
           
 boolean wasLockAcquired()
          indicates if the lock was acquired in the past....
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCK_PREFIX

public static final java.lang.String LOCK_PREFIX
See Also:
Constant Field Values
Constructor Detail

ZooLock

public ZooLock(java.lang.String path)
Method Detail

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.