Class AbstractWorkerStatusServlet

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

public abstract class AbstractWorkerStatusServlet extends javax.servlet.http.HttpServlet
This servlet accepts requests from a DispatcherClient to maintain worker liveness checks. To be used in conjunction with DispatcherPresenceLeaseHandler.
See Also:
  • 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(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
      Overrides:
      doPost in class javax.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