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
).Modifier and Type | Field and Description |
---|---|
private String |
description |
private String |
namespace |
private LockProcedure |
proc |
private RegionInfo[] |
regionInfos |
private TableName |
tableName |
private LockType |
type |
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.
|
(package private) LockProcedure |
getProc() |
void |
release()
Release the lock.
|
String |
toString() |
boolean |
tryAcquire(long timeoutMs)
Acquire the lock within a wait time.
|
private final RegionInfo[] regionInfos
private final String description
private LockProcedure proc
public MasterLock(String namespace, LockType type, String description)
public 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()
LockProcedure getProc()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.