public class LockManager.MasterLock extends Object
LockProcedure
which waits in a
queue until scheduled.
Use this lock instead LockManager.remoteLocks() for MASTER ONLY operations for two advantages:
- no need of polling on LockProcedure to check if lock was acquired.
- Generous timeout for lock preemption (default 10 min), no need to spawn thread for heartbeats.
(timeout configuration LockProcedure.DEFAULT_LOCAL_MASTER_LOCKS_TIMEOUT_MS
).Constructor and Description |
---|
MasterLock(RegionInfo[] regionInfos,
String description) |
MasterLock(String namespace,
LockType type,
String description) |
MasterLock(TableName tableName,
LockType type,
String description) |
Modifier and Type | Method and Description |
---|---|
boolean |
acquire()
Acquire the lock, waiting indefinitely until the lock is released or
the thread is interrupted.
|
void |
release()
Release the lock.
|
String |
toString() |
boolean |
tryAcquire(long timeoutMs)
Acquire the lock within a wait time.
|
public MasterLock(RegionInfo[] regionInfos, String description)
public boolean acquire() throws InterruptedException
InterruptedException
- If current thread is interrupted while
waiting for the lockpublic boolean tryAcquire(long timeoutMs) throws InterruptedException
timeoutMs
- The maximum time (in milliseconds) to wait for the lock,
0 to wait indefinitelyInterruptedException
- If the thread is interrupted while waiting to
acquire the lockpublic void release()
Copyright © 2007–2019 Cloudera. All rights reserved.