@InterfaceAudience.Private public class ZKInterProcessReadWriteLock extends Object implements InterProcessReadWriteLock
InterProcessReadWriteLock
. This lock is fair,
not reentrant, and not revocable.Modifier and Type | Field and Description |
---|---|
private InterProcessLock.MetadataHandler |
handler |
private ZooKeeperWatcher |
zkWatcher |
private String |
znode |
Constructor and Description |
---|
ZKInterProcessReadWriteLock(ZooKeeperWatcher zkWatcher,
String znode,
InterProcessLock.MetadataHandler handler)
Creates a DistributedReadWriteLock instance.
|
Modifier and Type | Method and Description |
---|---|
ZKInterProcessReadLock |
readLock(byte[] metadata)
Obtain a read lock containing given metadata.
|
ZKInterProcessWriteLock |
writeLock(byte[] metadata)
Obtain a write lock containing given metadata.
|
private final ZooKeeperWatcher zkWatcher
private final String znode
private final InterProcessLock.MetadataHandler handler
public ZKInterProcessReadWriteLock(ZooKeeperWatcher zkWatcher, String znode, InterProcessLock.MetadataHandler handler)
zkWatcher
- znode
- ZNode path for the lockhandler
- 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.public ZKInterProcessReadLock readLock(byte[] metadata)
readLock
in interface InterProcessReadWriteLock
metadata
- Serialized lock metadata (this may contain information
such as the process owning the lock or the purpose for
which the lock was acquired).public ZKInterProcessWriteLock writeLock(byte[] metadata)
writeLock
in interface InterProcessReadWriteLock
metadata
- Serialized lock metadata (this may contain information
such as the process owning the lock or the purpose for
which the lock was acquired).Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.