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.
LockAndQueueextendsProcedureDequeclass. 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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfilterWaitingQueue(Predicate<Procedure> predicate) Procedure<?>Get the procedure which holds the exclusive lock.intGet the number of procedures which hold the shared lock.booleanWhether the exclusive lock has been held.booleanhasLockAccess(Procedure<?> proc) Return true if the procedure itself holds the exclusive lock, or any ancestors of the give procedure hold the exclusive lock.booleanbooleanreleaseExclusiveLock(Procedure<?> proc) Returns whether we should wake the procedures waiting on the lock here.booleanReturns whether we should wake the procedures waiting on the lock here.Procedure<?>toString()booleantryExclusiveLock(Procedure<?> proc) booleantrySharedLock(Procedure<?> proc) Returns whether we have succesfully acquired the shared lock.intwakeWaitingProcedures(ProcedureScheduler scheduler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:LockStatusWhether the exclusive lock has been held.- Specified by:
hasExclusiveLockin interfaceLockStatus
-
hasLockAccess
Description copied from interface:LockStatusReturn true if the procedure itself holds the exclusive lock, or any ancestors of the give procedure hold the exclusive lock.- Specified by:
hasLockAccessin interfaceLockStatus
-
getExclusiveLockOwnerProcedure
Description copied from interface:LockStatusGet the procedure which holds the exclusive lock.- Specified by:
getExclusiveLockOwnerProcedurein interfaceLockStatus
-
tryExclusiveLock
-
releaseExclusiveLock
Returns whether we should wake the procedures waiting on the lock here. -
isWaitingQueueEmpty
-
removeFirst
-
addLast
-
wakeWaitingProcedures
-
filterWaitingQueue
-
toString
-