Class LockAndQueue
java.lang.Object
org.apache.hadoop.hbase.procedure2.LockAndQueue
- All Implemented Interfaces:
LockStatus
Locking for mutual exclusion between procedures. Used only by procedure framework internally.
There is no need of 'volatile' keyword for member variables because of memory synchronization guarantees of locks (see Memory Synchronization)
We do not implement Lock interface because we need exclusive and shared locking, and also because try-lock functions require procedure id.
We do not use ReentrantReadWriteLock directly because of its high memory overhead.
LockAndQueue
has two purposes:
- Acquire/release exclusive/shared locks.
- Maintains a list of procedures waiting on this lock.
LockAndQueue
extendsProcedureDeque
class. Blocked Procedures are added to our super Deque. Using inheritance over composition to keep the Deque of waiting Procedures is unusual, but we do it this way because in certain cases, there will be millions of regions. This layout uses less memory.
There is no need of 'volatile' keyword for member variables because of memory synchronization guarantees of locks (see Memory Synchronization)
We do not implement Lock interface because we need exclusive and shared locking, and also because try-lock functions require procedure id.
We do not use ReentrantReadWriteLock directly because of its high memory overhead.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
filterWaitingQueue
(Predicate<Procedure> predicate) Procedure<?>
Get the procedure which holds the exclusive lock.int
Get the number of procedures which hold the shared lock.boolean
Whether the exclusive lock has been held.boolean
hasLockAccess
(Procedure<?> proc) Return true if the procedure itself holds the exclusive lock, or any ancestors of the give procedure hold the exclusive lock.boolean
boolean
releaseExclusiveLock
(Procedure<?> proc) Returns whether we should wake the procedures waiting on the lock here.boolean
Returns whether we should wake the procedures waiting on the lock here.Procedure<?>
toString()
boolean
tryExclusiveLock
(Procedure<?> proc) boolean
trySharedLock
(Procedure<?> proc) Returns whether we have succesfully acquired the shared lock.int
wakeWaitingProcedures
(ProcedureScheduler scheduler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.procedure2.LockStatus
describeLockStatus, getExclusiveLockProcIdOwner, isLocked
-
Field Details
-
procedureRetriever
-
queue
-
exclusiveLockOwnerProcedure
-
-
Constructor Details
-
LockAndQueue
-
-
Method Details
-
hasExclusiveLock
Description copied from interface:LockStatus
Whether the exclusive lock has been held.- Specified by:
hasExclusiveLock
in interfaceLockStatus
-
hasLockAccess
Description copied from interface:LockStatus
Return true if the procedure itself holds the exclusive lock, or any ancestors of the give procedure hold the exclusive lock.- Specified by:
hasLockAccess
in interfaceLockStatus
-
getExclusiveLockOwnerProcedure
Description copied from interface:LockStatus
Get the procedure which holds the exclusive lock.- Specified by:
getExclusiveLockOwnerProcedure
in interfaceLockStatus
-
tryExclusiveLock
-
releaseExclusiveLock
Returns whether we should wake the procedures waiting on the lock here. -
isWaitingQueueEmpty
-
removeFirst
-
addLast
-
wakeWaitingProcedures
-
filterWaitingQueue
-
toString
-