Interface ProcedureStore

All Known Implementing Classes:
NoopProcedureStore, ProcedureStoreBase, RegionProcedureStore, WALProcedureStore

@Private @Evolving public interface ProcedureStore
The ProcedureStore is used by the executor to persist the state of each procedure execution. This allows to resume the execution of pending/in-progress procedures in case of machine failure or service shutdown.

Notice that, the implementation must guarantee that the maxProcId when loading is the maximum one in the whole history, not only the current live procedures. This is very important as for executing remote procedures, we have some nonce checks at region server side to prevent executing non-idempotent operations more than once. If the procedure id could go back, then we may accidentally ignore some important operations such as region assign or unassign.
This may lead to some garbages so we provide a cleanup() method, the framework will call this method periodically and the store implementation could do some clean up works in this method.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    An Iterator over a collection of Procedure
    static interface 
    Interface passed to the ProcedureStore.load() method to handle the store-load events.
    static interface 
    Store listener interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Will be called by the framework to give the store a chance to do some clean up works.
    void
    delete(long procId)
    The specified procId was removed from the executor, due to completion, abort or failure.
    void
    delete(long[] procIds, int offset, int count)
    The specified procIds were removed from the executor, due to completion, abort or failure.
    void
    delete(Procedure<?> parentProc, long[] subProcIds)
    The parent procedure completed.
    int
    Returns the number of threads/slots passed to start()
    void
    insert(Procedure<?>[] procs)
    Serialize a set of new procedures.
    void
    insert(Procedure<?> proc, Procedure<?>[] subprocs)
    When a procedure is submitted to the executor insert(proc, null) will be called.
    boolean
    Returns true if the store is running, otherwise false.
    void
    Load the Procedures in the store.
    void
    Deprecated.
    since 2.3.0, will be removed in 4.0.0 along with WALProcedureStore.
    void
    Add the listener to the notification list.
    int
    Set the number of procedure running.
    void
    start(int numThreads)
    Start/Open the procedure store
    void
    stop(boolean abort)
    Stop/Close the procedure store
    boolean
    Remove the listener from the notification list.
    void
    update(Procedure<?> proc)
    The specified procedure was executed, and the new state should be written to the store.
  • Method Details

    • registerListener

      Add the listener to the notification list.
      Parameters:
      listener - The AssignmentListener to register
    • unregisterListener

      Remove the listener from the notification list.
      Parameters:
      listener - The AssignmentListener to unregister
      Returns:
      true if the listner was in the list and it was removed, otherwise false.
    • start

      void start(int numThreads) throws IOException
      Start/Open the procedure store
      Parameters:
      numThreads - number of threads to be used by the procedure store
      Throws:
      IOException
    • stop

      void stop(boolean abort)
      Stop/Close the procedure store
      Parameters:
      abort - true if the stop is an abort
    • isRunning

      boolean isRunning()
      Returns true if the store is running, otherwise false.
    • getNumThreads

      Returns the number of threads/slots passed to start()
    • setRunningProcedureCount

      int setRunningProcedureCount(int count)
      Set the number of procedure running. This can be used, for example, by the store to know how long to wait before a sync.
      Returns:
      how many procedures are running (may not be same as count).
    • recoverLease

      Deprecated.
      since 2.3.0, will be removed in 4.0.0 along with WALProcedureStore. As now we will store the procedure data in a master local region, and master itself will deal with the lease recovery of the region.
      Acquire the lease for the procedure store.
      Throws:
      IOException
    • load

      Load the Procedures in the store.
      Parameters:
      loader - the ProcedureLoader that will handle the store-load events
      Throws:
      IOException
    • insert

      void insert(Procedure<?> proc, Procedure<?>[] subprocs)
      When a procedure is submitted to the executor insert(proc, null) will be called. 'proc' has a 'RUNNABLE' state and the initial information required to start up. When a procedure is executed and it returns children insert(proc, subprocs) will be called. 'proc' has a 'WAITING' state and an update state. 'subprocs' are the children in 'RUNNABLE' state with the initial information.
      Parameters:
      proc - the procedure to serialize and write to the store.
      subprocs - the newly created child of the proc.
    • insert

      void insert(Procedure<?>[] procs)
      Serialize a set of new procedures. These procedures are freshly submitted to the executor and each procedure has a 'RUNNABLE' state and the initial information required to start up.
      Parameters:
      procs - the procedures to serialize and write to the store.
    • update

      void update(Procedure<?> proc)
      The specified procedure was executed, and the new state should be written to the store.
      Parameters:
      proc - the procedure to serialize and write to the store.
    • delete

      void delete(long procId)
      The specified procId was removed from the executor, due to completion, abort or failure. The store implementor should remove all the information about the specified procId.
      Parameters:
      procId - the ID of the procedure to remove.
    • delete

      void delete(Procedure<?> parentProc, long[] subProcIds)
      The parent procedure completed. Update the state and mark all the child deleted.
      Parameters:
      parentProc - the parent procedure to serialize and write to the store.
      subProcIds - the IDs of the sub-procedure to remove.
    • delete

      void delete(long[] procIds, int offset, int count)
      The specified procIds were removed from the executor, due to completion, abort or failure. The store implementor should remove all the information about the specified procIds.
      Parameters:
      procIds - the IDs of the procedures to remove.
      offset - the array offset from where to start to delete
      count - the number of IDs to delete
    • cleanup

      default void cleanup()
      Will be called by the framework to give the store a chance to do some clean up works.

      Notice that this is for periodical clean up work, not for the clean up after close, if you want to close the store just call the stop(boolean) method above.