Class AbstractWorkerStatusServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.illumon.iris.db.tables.remotequery.keepalive.AbstractWorkerStatusServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public abstract class AbstractWorkerStatusServlet extends jakarta.servlet.http.HttpServlet
This servlet accepts requests from a DispatcherClient to maintain worker liveness checks. To be used in conjunction with DispatcherPresenceLeaseHandler.
See Also:
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractWorkerStatusServlet(com.fishlib.io.logger.Logger log, boolean workerDetailsEnabled, long workerTtlMillis)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract SafeCloseable
    A lock to protect worker state.
    protected void
    doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    getWorker(String workerProcessId)
     
    abstract io.deephaven.enterprise.dispatcher.client.WorkerDetails
    On registration, the worker may ask for its details.
    abstract void
     
    abstract String
    registerWorker(String workerProcessId, SafeCloseable lock)
    Called on the first status from a worker.
    abstract void
    terminateWorker(String workerProcessId, SafeCloseable lockCloseable, String message)
    Terminate the given worker.

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, init, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractWorkerStatusServlet

      public AbstractWorkerStatusServlet(com.fishlib.io.logger.Logger log, boolean workerDetailsEnabled, long workerTtlMillis)
      Parameters:
      log - log
      workerDetailsEnabled - true if we can produce worker details, otherwise if they are requested we reject the registration
      workerTtlMillis - the number of milliseconds allowed between worker status POST requests
  • Method Details

    • doPost

      protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException
      Overrides:
      doPost in class jakarta.servlet.http.HttpServlet
      Throws:
      IOException
    • registerWorker

      public abstract String registerWorker(String workerProcessId, SafeCloseable lock)
      Called on the first status from a worker.
      Parameters:
      workerProcessId - the process info ID of the worker
      lock - a lock that may be closed before calling expensive operations like sending a response
      Returns:
      null if registration is successful, an error message otherwise
    • onReady

      public abstract void onReady(KeepAliveWorker worker, SafeCloseable lock)
      Parameters:
      worker - called when the worker transitions from initializing to ready
      lock - a lock that may be closed before calling expensive operations like sending a response
    • getWorkerDetails

      @NotNull public abstract io.deephaven.enterprise.dispatcher.client.WorkerDetails getWorkerDetails(KeepAliveWorker worker)
      On registration, the worker may ask for its details. This method will only be called if workerDetailsEnabled was set to true in the constructor.
      Parameters:
      worker - the worker to get details for
      Returns:
      the details associated with this worker
    • getWorker

      public abstract KeepAliveWorker getWorker(String workerProcessId)
      Parameters:
      workerProcessId - the process info ID of a worker status request
      Returns:
      the KeepAliveWorker corresponding to the process info id
    • terminateWorker

      public abstract void terminateWorker(String workerProcessId, SafeCloseable lockCloseable, String message)
      Terminate the given worker.

      For a dispatcher, this should actually terminate the underlying worker process or container. For other lease handlers, it should simply remove the lease that keeps the worker alive.

      Parameters:
      workerProcessId - the process info ID of the worker
      lockCloseable - a SafeCloseable that is released before terminating the worker or performing long-lived I/O. This may or may not be closed, and the caller should be prepared to close it without error if it is closed twice.
      message - the message for termination
    • acquireLock

      public abstract SafeCloseable acquireLock()
      A lock to protect worker state. The lock will be closed at least once, but may be closed multiple times.
      Returns:
      a lock that protects worker state