Interface ProcedureScheduler

All Known Implementing Classes:
AbstractProcedureScheduler, MasterProcedureScheduler, SimpleProcedureScheduler

@Private public interface ProcedureScheduler
Keep track of the runnable procedures
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Inserts the specified element at the end of this queue.
    void
    addBack(Procedure proc, boolean notify)
    Inserts the specified element at the end of this queue.
    void
    addFront(Iterator<Procedure> procedureIterator)
    Inserts all elements in the iterator at the front of this queue.
    void
    Inserts the specified element at the front of this queue.
    void
    addFront(Procedure proc, boolean notify)
    Inserts the specified element at the front of this queue.
    void
    Clear current state of scheduler such that it is equivalent to newly created scheduler.
    void
    The procedure in execution completed.
    getLockResource(LockedResourceType resourceType, String resourceName)
     
    List lock queues.
    boolean
    Returns true if there are procedures available to process, otherwise false.
    Fetch one Procedure from the queue
    poll(long timeout, TimeUnit unit)
    Fetch one Procedure from the queue
    void
    In case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.
    int
    Returns the number of elements in this queue.
    void
    Start the scheduler
    void
    Stop the scheduler
    void
    The procedure can't run at the moment.
  • Method Details

    • start

      void start()
      Start the scheduler
    • stop

      void stop()
      Stop the scheduler
    • signalAll

      void signalAll()
      In case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.
    • addFront

      void addFront(Procedure proc)
      Inserts the specified element at the front of this queue.
      Parameters:
      proc - the Procedure to add
    • addFront

      void addFront(Procedure proc, boolean notify)
      Inserts the specified element at the front of this queue.
      Parameters:
      proc - the Procedure to add
      notify - whether need to notify worker
    • addFront

      void addFront(Iterator<Procedure> procedureIterator)
      Inserts all elements in the iterator at the front of this queue.
    • addBack

      void addBack(Procedure proc)
      Inserts the specified element at the end of this queue.
      Parameters:
      proc - the Procedure to add
    • addBack

      void addBack(Procedure proc, boolean notify)
      Inserts the specified element at the end of this queue.
      Parameters:
      proc - the Procedure to add
      notify - whether need to notify worker
    • yield

      void yield(Procedure proc)
      The procedure can't run at the moment. add it back to the queue, giving priority to someone else.
      Parameters:
      proc - the Procedure to add back to the list
    • completionCleanup

      The procedure in execution completed. This can be implemented to perform cleanups.
      Parameters:
      proc - the Procedure that completed the execution.
    • hasRunnables

      boolean hasRunnables()
      Returns true if there are procedures available to process, otherwise false.
    • poll

      Fetch one Procedure from the queue
      Returns:
      the Procedure to execute, or null if nothing present.
    • poll

      Procedure poll(long timeout, TimeUnit unit)
      Fetch one Procedure from the queue
      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.
    • getLocks

      List lock queues.
      Returns:
      the locks
    • getLockResource

      Returns:
      LockedResource for resource of specified type & name. null if resource is not locked.
    • size

      int size()
      Returns the number of elements in this queue.
      Returns:
      the number of elements in this queue.
    • clear

      void clear()
      Clear current state of scheduler such that it is equivalent to newly created scheduler. Used for testing failure and recovery. To emulate server crash/restart, ProcedureExecutor resets its own state and calls clear() on scheduler.