Interface PersistentQueryHandle

All Known Implementing Classes:
CommunityPersistentQueryHandle, DoNothingHandle, EnterprisePersistentQueryHandle, PersistentQueryHandleBase

public interface PersistentQueryHandle
This interface defines a local handle to a remote Persistent Query. The query may be an Enterprise worker, or a Community worker.
  • Method Details

    • getVersion

      long getVersion()
      Get the currently running version of the Persistent Query.
      Returns:
      the version of the running query
    • getState

      Get the current state object for the Persistent Query.
      Returns:
      the current state
    • start

      void start(long shouldStopTimeMillis)
      Start the worker. Only one of start() or restore() should be called after construction.
      Parameters:
      shouldStopTimeMillis - The scheduled stopping time for scheduled configs, or zero otherwise.
    • restore

      default boolean restore(@NotNull PersistentQueryState oldState, long deadlineMillis)
      Attempt to restore a worker. Only one of start() or restore() should be called after construction.
      Parameters:
      oldState - the old PQ state from where to attempt to restore
      deadlineMillis - the deadline for restoring this worker (in millis since the epoch)
      Returns:
      true if the restore attempt succeeded
    • canTryToRestore

      default boolean canTryToRestore()
      Check whether the class of this object can attempt to restore already running workers.
      Returns:
      true if the class of this object can attempt to restore an already running worker
    • shutdown

      void shutdown(@Nullable UserContext userContext)
      Shutdown the worker, if it is running. This method blocks until shutdown is complete.
      Parameters:
      userContext - the user attempting the shutdown null indicates the controller itself.
    • setReplicaSlot

      void setReplicaSlot(int replicaSlot)
      Set the replica slot for this handle.
      Parameters:
      replicaSlot - the replica slot.
    • getWorkerHandle

      @Nullable WorkerHandle getWorkerHandle()
      Get the WorkerHandle for an active worker. May return null if the worker is not running.
      Returns:
      the WorkerHandle or null if the worker is not running
    • getStateLock

      @NotNull Object getStateLock()
      Get the object used to protect state changes. This can be used when coordinated changes need to be made to more than one handle at a time, for example in the case of a state swap (see QueryTracker#enqueueShuffle()
      Returns:
      the state lock