Class LockAndQueue

java.lang.Object
org.apache.hadoop.hbase.procedure2.LockAndQueue
All Implemented Interfaces:
LockStatus

@Private public class LockAndQueue extends Object implements LockStatus
Locking for mutual exclusion between procedures. Used only by procedure framework internally. LockAndQueue has two purposes:
  1. Acquire/release exclusive/shared locks.
  2. Maintains a list of procedures waiting on this lock. LockAndQueue extends ProcedureDeque 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.

NOT thread-safe. Needs external concurrency control: e.g. uses in MasterProcedureScheduler are guarded by schedLock().
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.