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).| 构造器和说明 |
|---|
MasterLock(RegionInfo[] regionInfos,
String description) |
MasterLock(String namespace,
LockType type,
String description) |
MasterLock(TableName tableName,
LockType type,
String description) |
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 The Apache Software Foundation. All rights reserved.