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

java.lang.Object
  extended by org.apache.hadoop.hbase.zookeeper.lock.ZKInterProcessReadWriteLock
All Implemented Interfaces:
InterProcessReadWriteLock

@InterfaceAudience.Private
public class ZKInterProcessReadWriteLock
extends Object
implements InterProcessReadWriteLock

ZooKeeper based implementation of InterProcessReadWriteLock. This lock is fair, not reentrant, and not revocable.


Constructor Summary
ZKInterProcessReadWriteLock(ZooKeeperWatcher zkWatcher, String znode, InterProcessLock.MetadataHandler handler)
          Creates a DistributedReadWriteLock instance.
 
Method Summary
 ZKInterProcessReadLock readLock(byte[] metadata)
          Obtain a read lock containing given metadata.
 ZKInterProcessWriteLock writeLock(byte[] metadata)
          Obtain a write lock containing given metadata.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZKInterProcessReadWriteLock

public ZKInterProcessReadWriteLock(ZooKeeperWatcher zkWatcher,
                                   String znode,
                                   InterProcessLock.MetadataHandler handler)
Creates a DistributedReadWriteLock instance.

Parameters:
zkWatcher -
znode - ZNode path for the lock
handler - An object that will handle de-serializing and processing the metadata associated with reader or writer locks created by this object or null if none desired.
Method Detail

readLock

public ZKInterProcessReadLock readLock(byte[] metadata)
Obtain a read lock containing given metadata.

Specified by:
readLock in interface InterProcessReadWriteLock
Parameters:
metadata - Serialized lock metadata (this may contain information such as the process owning the lock or the purpose for which the lock was acquired).
Returns:
An instantiated InterProcessLock instance

writeLock

public ZKInterProcessWriteLock writeLock(byte[] metadata)
Obtain a write lock containing given metadata.

Specified by:
writeLock in interface InterProcessReadWriteLock
Parameters:
metadata - Serialized lock metadata (this may contain information such as the process owning the lock or the purpose for which the lock was acquired).
Returns:
An instantiated InterProcessLock instance


Copyright © 2015 The Apache Software Foundation. All rights reserved.