org.apache.hadoop.hbase.util
Class KeyLocker<K extends Comparable<? super K>>
java.lang.Object
org.apache.hadoop.hbase.util.KeyLocker<K>
@InterfaceAudience.Private
public class KeyLocker<K extends Comparable<? super K>>
- extends Object
A utility class to manage a set of locks. Each lock is identified by a String which serves
as a key. Typical usage is:
class Example{
private final static KeyLocker locker = new Locker();
public void foo(String s){
Lock lock = locker.acquireLock(s);
try {
// whatever
}finally{
lock.unlock();
}
}
}
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
KeyLocker
public KeyLocker()
acquireLock
public ReentrantLock acquireLock(K key)
- Return a lock for the given key. The lock is already locked.
- Parameters:
key
-
acquireLocks
public Map<K,Lock> acquireLocks(Set<K> keys)
- Acquire locks for a set of keys. The keys will be
sorted internally to avoid possible deadlock.
Copyright © 2015 The Apache Software Foundation. All Rights Reserved.