org.apache.hadoop.hbase.zookeeper.lock
Class ZKInterProcessReadLock

java.lang.Object
  extended by org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessLockBase
      extended by org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessReadLock
All Implemented Interfaces:
InterProcessLock

@InterfaceAudience.Private
public class ZKInterProcessReadLock
extends ZKInterProcessLockBase

ZooKeeper based read lock: does not exclude other read locks, but excludes and is excluded by write locks.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessLockBase
ZKInterProcessLockBase.AcquiredLock, ZKInterProcessLockBase.ZNodeComparator
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.InterProcessLock
InterProcessLock.MetadataHandler
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessLockBase
acquiredLock, fullyQualifiedZNode, handler, metadata, parentLockNode, READ_LOCK_CHILD_NODE_PREFIX, WRITE_LOCK_CHILD_NODE_PREFIX, zkWatcher
 
Constructor Summary
ZKInterProcessReadLock(ZooKeeperWatcher zooKeeperWatcher, String znode, byte[] metadata, InterProcessLock.MetadataHandler handler)
           
 
Method Summary
protected  String getLockPath(String createdZNode, List<String> children)
          Determine based on a list of children under a ZNode, whether or not a process which created a specified ZNode has obtained a lock.
 void reapAllLocks()
          If supported, attempts to reap all the locks of this type by forcefully deleting the locks.
 
Methods inherited from class org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessLockBase
acquire, handleLockMetadata, isChildWriteLock, release, tryAcquire, updateAcquiredLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZKInterProcessReadLock

public ZKInterProcessReadLock(ZooKeeperWatcher zooKeeperWatcher,
                              String znode,
                              byte[] metadata,
                              InterProcessLock.MetadataHandler handler)
Method Detail

getLockPath

protected String getLockPath(String createdZNode,
                             List<String> children)
                      throws IOException,
                             InterruptedException
Determine based on a list of children under a ZNode, whether or not a process which created a specified ZNode has obtained a lock. If a lock is not obtained, return the path that we should watch awaiting its deletion. Otherwise, return null. This method is abstract as the logic for determining whether or not a lock is obtained depends on the type of lock being implemented.

Specified by:
getLockPath in class ZKInterProcessLockBase
Parameters:
createdZNode - The ZNode created by the process attempting to acquire a lock
children - List of all child ZNodes under the lock's parent ZNode
Returns:
The path to watch, or null if myZNode can represent a correctly acquired lock.
Throws:
IOException
InterruptedException

reapAllLocks

public void reapAllLocks()
                  throws IOException
Description copied from interface: InterProcessLock
If supported, attempts to reap all the locks of this type by forcefully deleting the locks. 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


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.