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 Summary
ConstructorsConstructorDescriptionAbstractWorkerStatusServlet
(com.fishlib.io.logger.Logger log, boolean workerDetailsEnabled, long workerTtlMillis) -
Method Summary
Modifier and TypeMethodDescriptionabstract SafeCloseable
A lock to protect worker state.protected void
doPost
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) abstract KeepAliveWorker
abstract io.deephaven.enterprise.dispatcher.client.WorkerDetails
getWorkerDetails
(KeepAliveWorker worker) On registration, the worker may ask for its details.abstract void
onReady
(KeepAliveWorker worker, SafeCloseable lock) 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 javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Constructor Details
-
AbstractWorkerStatusServlet
public AbstractWorkerStatusServlet(com.fishlib.io.logger.Logger log, boolean workerDetailsEnabled, long workerTtlMillis) - Parameters:
log
- logworkerDetailsEnabled
- true if we can produce worker details, otherwise if they are requested we reject the registrationworkerTtlMillis
- 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 classjavax.servlet.http.HttpServlet
- Throws:
IOException
-
registerWorker
Called on the first status from a worker.- Parameters:
workerProcessId
- the process info ID of the workerlock
- 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
- Parameters:
worker
- called when the worker transitions from initializing to readylock
- 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
- 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 workerlockCloseable
- 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
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
-