Class PersistentQueryHandleBase

java.lang.Object
com.illumon.iris.controller.handle.PersistentQueryHandleBase
All Implemented Interfaces:
PersistentQueryHandle
Direct Known Subclasses:
CommunityPersistentQueryHandle, DoNothingHandle, EnterprisePersistentQueryHandle

public abstract class PersistentQueryHandleBase extends Object implements PersistentQueryHandle
  • Field Details

  • Constructor Details

    • PersistentQueryHandleBase

      protected PersistentQueryHandleBase(@NotNull com.fishlib.io.logger.Logger log, @NotNull Object queryHandleContext)
      Create a new PQ Handle. Note after creating the object, one of two things should happen: either start or restore should be called.
      Parameters:
      log - the log.
      queryHandleContext - A context object containing the required parameters for this object.
  • Method Details

    • onStartRequested

      protected abstract void onStartRequested()
    • onDispatcherConnected

      protected abstract boolean onDispatcherConnected(@NotNull QueryDispatcherConnection connection)
    • createWorkerHandle

      protected abstract WorkerHandle createWorkerHandle(RemoteProcessingRequest request, QueryDispatcherConnection dispatcherConnection)
    • getWorkerHandle

      @Nullable public WorkerHandle getWorkerHandle()
      Description copied from interface: PersistentQueryHandle
      Get the WorkerHandle for an active worker. May return null if the worker is not running.
      Specified by:
      getWorkerHandle in interface PersistentQueryHandle
      Returns:
      the WorkerHandle or null if the worker is not running
    • getVersion

      public long getVersion()
      Description copied from interface: PersistentQueryHandle
      Get the currently running version of the Persistent Query.
      Specified by:
      getVersion in interface PersistentQueryHandle
      Returns:
      the version of the running query
    • getState

      public PersistentQueryState getState()
      Description copied from interface: PersistentQueryHandle
      Get the current state object for the Persistent Query.
      Specified by:
      getState in interface PersistentQueryHandle
      Returns:
      the current state
    • start

      public void start(long whenToStopMillis)
      Description copied from interface: PersistentQueryHandle
      Start the worker. Only one of start() or restore() should be called after construction.
      Specified by:
      start in interface PersistentQueryHandle
      Parameters:
      whenToStopMillis - The scheduled stopping time for scheduled configs, or zero otherwise.
    • restore

      protected boolean restore(WorkerHandle workerHandle, PersistentQueryState oldState)
      If this PQ Handle object is being recreated from saved state, instead of start being called this method restores the object.
      Parameters:
      workerHandle - a worker handle to use as our own
      Returns:
      true if we were able to restore this object, false otherwise
    • shutdown

      public void shutdown(String lastAuthenticatedUser, String lastEffectiveUser)
      Description copied from interface: PersistentQueryHandle
      Shutdown the worker, if it is running.
      Specified by:
      shutdown in interface PersistentQueryHandle
      Parameters:
      lastAuthenticatedUser - the authenticating user requesting the shutdown
      lastEffectiveUser - the effective user requesting the shuutdown
    • ensureShutdown

      protected void ensureShutdown(boolean awaitDisconnection)
      Parameters:
      awaitDisconnection - Used to communicate whether we need to care further about ensuring disconnection, or not. If true, we block until interrupted or until another thread calls ensureShutdown(false). If false, we're asserting that the DB is already disconnected, or that we don't care (because no script was run yet).
    • checkQueryTerminatingOrTerminal

      protected boolean checkQueryTerminatingOrTerminal()
    • maybeSetTerminalStatus

      protected boolean maybeSetTerminalStatus(Supplier<PersistentQueryState.Status> statusSupplier)
    • onError

      protected void onError(@Nullable Throwable t)
    • onFailure

      protected void onFailure(@Nullable Throwable t, @Nullable String processInfoId, boolean awaitDisconnection)
    • onFailure

      protected void onFailure(@Nullable Throwable t, @Nullable String processInfoId, boolean awaitDisconnection, @Nullable String message)
    • publishState

      protected void publishState()
    • getScriptCode

      protected String getScriptCode()