Class ProcedureEvent<T>

java.lang.Object
org.apache.hadoop.hbase.procedure2.ProcedureEvent<T>
Direct Known Subclasses:
RegionStateNode.AssignmentProcedureEvent

@Private public class ProcedureEvent<T> extends Object
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 Details

  • Constructor Details

  • Method Details

    • isReady

      public boolean isReady()
    • suspendIfNotReady

      public boolean suspendIfNotReady(Procedure proc)
      Returns true if event is not ready and adds procedure to suspended queue, else returns false.
    • suspend

      public void suspend()
      Mark the event as not ready.
    • wake

      public void wake(AbstractProcedureScheduler procedureScheduler)
      Wakes up the suspended procedures by pushing them back into scheduler queues and sets the event as ready. See wakeInternal(AbstractProcedureScheduler) for why this is not synchronized.
    • wakeIfSuspended

      public boolean wakeIfSuspended(AbstractProcedureScheduler procedureScheduler, Procedure<?> proc)
      Wakes up the suspended procedures only if the given proc 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

      public static void wakeEvents(AbstractProcedureScheduler scheduler, ProcedureEvent... events)
      Wakes up all the given events and puts the procedures waiting on them back into ProcedureScheduler queues.
    • wakeInternal

      public void wakeInternal(AbstractProcedureScheduler procedureScheduler)
      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

      public String toString()
      Overrides:
      toString in class Object