Class AbstractProcedureScheduler

java.lang.Object
org.apache.hadoop.hbase.procedure2.AbstractProcedureScheduler
All Implemented Interfaces:
ProcedureScheduler
Direct Known Subclasses:
MasterProcedureScheduler, SimpleProcedureScheduler

@Private public abstract class AbstractProcedureScheduler extends Object implements ProcedureScheduler
  • Field Details

  • Constructor Details

  • Method Details

    • start

      public void start()
      Description copied from interface: ProcedureScheduler
      Start the scheduler
      Specified by:
      start in interface ProcedureScheduler
    • stop

      public void stop()
      Description copied from interface: ProcedureScheduler
      Stop the scheduler
      Specified by:
      stop in interface ProcedureScheduler
    • signalAll

      public void signalAll()
      Description copied from interface: ProcedureScheduler
      In case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.
      Specified by:
      signalAll in interface ProcedureScheduler
    • enqueue

      protected abstract void enqueue(Procedure procedure, boolean addFront)
      Add the procedure to the queue. NOTE: this method is called with the sched lock held.
      Parameters:
      procedure - the Procedure to add
      addFront - true if the item should be added to the front of the queue
    • addFront

      public void addFront(Procedure procedure)
      Description copied from interface: ProcedureScheduler
      Inserts the specified element at the front of this queue.
      Specified by:
      addFront in interface ProcedureScheduler
      Parameters:
      procedure - the Procedure to add
    • addFront

      public void addFront(Procedure procedure, boolean notify)
      Description copied from interface: ProcedureScheduler
      Inserts the specified element at the front of this queue.
      Specified by:
      addFront in interface ProcedureScheduler
      Parameters:
      procedure - the Procedure to add
      notify - whether need to notify worker
    • addFront

      public void addFront(Iterator<Procedure> procedureIterator)
      Description copied from interface: ProcedureScheduler
      Inserts all elements in the iterator at the front of this queue.
      Specified by:
      addFront in interface ProcedureScheduler
    • addBack

      public void addBack(Procedure procedure)
      Description copied from interface: ProcedureScheduler
      Inserts the specified element at the end of this queue.
      Specified by:
      addBack in interface ProcedureScheduler
      Parameters:
      procedure - the Procedure to add
    • addBack

      public void addBack(Procedure procedure, boolean notify)
      Description copied from interface: ProcedureScheduler
      Inserts the specified element at the end of this queue.
      Specified by:
      addBack in interface ProcedureScheduler
      Parameters:
      procedure - the Procedure to add
      notify - whether need to notify worker
    • push

      protected void push(Procedure procedure, boolean addFront, boolean notify)
    • dequeue

      protected abstract Procedure dequeue()
      Fetch one Procedure from the queue NOTE: this method is called with the sched lock held.
      Returns:
      the Procedure to execute, or null if nothing is available.
    • poll

      public Procedure poll()
      Description copied from interface: ProcedureScheduler
      Fetch one Procedure from the queue
      Specified by:
      poll in interface ProcedureScheduler
      Returns:
      the Procedure to execute, or null if nothing present.
    • poll

      public Procedure poll(long timeout, TimeUnit unit)
      Description copied from interface: ProcedureScheduler
      Fetch one Procedure from the queue
      Specified by:
      poll in interface ProcedureScheduler
      Parameters:
      timeout - how long to wait before giving up, in units of unit
      unit - a TimeUnit determining how to interpret the timeout parameter
      Returns:
      the Procedure to execute, or null if nothing present.
    • poll

      public Procedure poll(long nanos)
    • queueSize

      protected abstract int queueSize()
      Returns the number of elements in this queue. NOTE: this method is called with the sched lock held.
      Returns:
      the number of elements in this queue.
    • queueHasRunnables

      protected abstract boolean queueHasRunnables()
      Returns true if there are procedures available to process. NOTE: this method is called with the sched lock held.
      Returns:
      true if there are procedures available to process, otherwise false.
    • size

      public int size()
      Description copied from interface: ProcedureScheduler
      Returns the number of elements in this queue.
      Specified by:
      size in interface ProcedureScheduler
      Returns:
      the number of elements in this queue.
    • hasRunnables

      public boolean hasRunnables()
      Description copied from interface: ProcedureScheduler
      Returns true if there are procedures available to process, otherwise false.
      Specified by:
      hasRunnables in interface ProcedureScheduler
    • getPollCalls

      public long getPollCalls()
    • getNullPollCalls

      public long getNullPollCalls()
    • wakeEvents

      void wakeEvents(ProcedureEvent[] events)
      Wake up all the given events. Note that we first take scheduler lock and then wakeInternal() synchronizes on the event. Access should remain package-private. Use ProcedureEvent class to wake/suspend events.
      Parameters:
      events - the list of events to wake
    • wakeWaitingProcedures

      protected int wakeWaitingProcedures(LockAndQueue lockAndQueue)
      Wakes up given waiting procedures by pushing them back into scheduler queues.
      Returns:
      size of given waitQueue.
    • waitProcedure

      protected void waitProcedure(LockAndQueue lockAndQueue, Procedure proc)
    • wakeProcedure

      protected void wakeProcedure(Procedure procedure)
    • schedLock

      protected void schedLock()
    • schedUnlock

      protected void schedUnlock()
    • wakePollIfNeeded

      protected void wakePollIfNeeded(int waitingCount)
    • toString

      public String toString()
      Overrides:
      toString in class Object