Class ProcedureEvent<T>
java.lang.Object
org.apache.hadoop.hbase.procedure2.ProcedureEvent<T>
- Direct Known Subclasses:
RegionStateNode.AssignmentProcedureEvent
Basic ProcedureEvent that contains an "object", which can be a description or a reference to the
resource to wait on, and a queue for suspended procedures.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final org.slf4j.Logger
private final T
private boolean
private ProcedureDeque
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAccess to suspendedProcedures is 'synchronized' on this object, but it's fine to return it here for tests.boolean
isReady()
void
suspend()
Mark the event as not ready.boolean
suspendIfNotReady
(Procedure proc) Returns true if event is not ready and adds procedure to suspended queue, else returns false.toString()
void
wake
(AbstractProcedureScheduler procedureScheduler) Wakes up the suspended procedures by pushing them back into scheduler queues and sets the event as ready.static void
wakeEvents
(AbstractProcedureScheduler scheduler, ProcedureEvent... events) Wakes up all the given events and puts the procedures waiting on them back into ProcedureScheduler queues.boolean
wakeIfSuspended
(AbstractProcedureScheduler procedureScheduler, Procedure<?> proc) Wakes up the suspended procedures only if the givenproc
is waiting on this event.void
wakeInternal
(AbstractProcedureScheduler procedureScheduler) Only to be used by ProcedureScheduler implementations.
-
Field Details
-
LOG
-
object
-
ready
-
suspendedProcedures
-
-
Constructor Details
-
ProcedureEvent
-
-
Method Details
-
isReady
-
suspendIfNotReady
Returns true if event is not ready and adds procedure to suspended queue, else returns false. -
suspend
Mark the event as not ready. -
wake
Wakes up the suspended procedures by pushing them back into scheduler queues and sets the event as ready. SeewakeInternal(AbstractProcedureScheduler)
for why this is not synchronized. -
wakeIfSuspended
Wakes up the suspended procedures only if the givenproc
is waiting on this event. Mainly used by region assignment to reject stale OpenRegionProcedure/CloseRegionProcedure. Use with caution as it will cause performance issue if there are lots of procedures waiting on the event. -
wakeEvents
Wakes up all the given events and puts the procedures waiting on them back into ProcedureScheduler queues. -
wakeInternal
Only to be used by ProcedureScheduler implementations. Reason: To wake up multiple events, locking sequence is schedLock --> synchronized (event) To wake up an event, both schedLock() and synchronized(event) are required. The order is schedLock() --> synchronized(event) because when waking up multiple events simultaneously, we keep the scheduler locked until all procedures suspended on these events have been added back to the queue (Maybe it's not required? Evaluate!) To avoid deadlocks, we want to keep the locking order same even when waking up single event. That's why,wake(AbstractProcedureScheduler)
above uses the same code path as used when waking up multiple events. Access should remain package-private. -
getSuspendedProcedures
Access to suspendedProcedures is 'synchronized' on this object, but it's fine to return it here for tests. -
toString
-