java.lang.Object
com.illumon.iris.db.tables.remotequery.process.BaseWorker
All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, KeepAliveWorker, Worker
Direct Known Subclasses:
K8SWorkerImpl

public abstract class BaseWorker extends Object implements Worker
This abstract class implements the Worker interface, which the RemoteQueryDispatcher now uses. The fields of this class were extracted from the RemoteQueryDispatcher and getter/setter methods were added.
  • Field Details

    • log

      protected final com.fishlib.io.logger.Logger log
    • clientConnectionAddress

      protected String clientConnectionAddress
  • Method Details

    • append

      public com.fishlib.base.log.LogOutput append(com.fishlib.base.log.LogOutput logOutput)
      Specified by:
      append in interface com.fishlib.base.log.LogOutputAppendable
    • getName

      public String getName()
      Description copied from interface: KeepAliveWorker
      Returns the name of this Worker.
      Specified by:
      getName in interface KeepAliveWorker
      Returns:
      the name of this Worker
    • getWorkerId

      public String getWorkerId()
      Description copied from interface: Worker
      Returns the id of this Worker
      Specified by:
      getWorkerId in interface Worker
      Returns:
      the id of this Worker
    • getProcessInfoId

      public String getProcessInfoId()
      Description copied from interface: KeepAliveWorker
      Returns the unique id of this Worker process
      Specified by:
      getProcessInfoId in interface KeepAliveWorker
      Returns:
      the unique id of this Worker process
    • getWorkerNonce

      public String getWorkerNonce()
      Description copied from interface: KeepAliveWorker
      Returns the nonce for registering this worker process
      Specified by:
      getWorkerNonce in interface KeepAliveWorker
      Returns:
      the nonce used for registration
    • getClientConnectionAddress

      public String getClientConnectionAddress()
      Description copied from interface: Worker
      Returns the client connection address this Worker, which could be a hostname, IP, FQDN, service name, endpoint, etc. Clients will connect to the Worker via ClientConnectionAddress:Port
      Specified by:
      getClientConnectionAddress in interface Worker
      Returns:
      the clientConnectionAddress of this Worker
    • getUserName

      public String getUserName()
      Description copied from interface: Worker
      Returns the userName of this Worker
      Specified by:
      getUserName in interface Worker
      Returns:
      the userName of this Worker
    • getRemoteProcessingRequest

      public RemoteProcessingRequest getRemoteProcessingRequest()
      Description copied from interface: Worker
      Returns the remoteProcessingRequest of this Worker
      Specified by:
      getRemoteProcessingRequest in interface Worker
      Returns:
      the remoteProcessingRequest of this Worker.
    • getClientClassDirectory

      public File getClientClassDirectory()
      Description copied from interface: Worker
      Returns the clientClassDirectory of this Worker
      Specified by:
      getClientClassDirectory in interface Worker
      Returns:
      the clientClassDirectory of this Worker.
    • getHeapSizeMB

      public int getHeapSizeMB()
      Description copied from interface: Worker
      Returns the heapSizeMB of this Worker
      Specified by:
      getHeapSizeMB in interface Worker
      Returns:
      the heapSizeMB of this Worker.
    • getAdditionalMemoryMB

      public int getAdditionalMemoryMB()
      Description copied from interface: Worker
      Returns the additional allocated memory for this worker.
      Specified by:
      getAdditionalMemoryMB in interface Worker
      Returns:
      the additional memory allocated for this worker, in megabytes
    • getPort

      public OptionalInt getPort(String protocol)
      Description copied from interface: Worker
      Returns the port of this Worker
      Specified by:
      getPort in interface Worker
      Parameters:
      protocol - the protocol to get a port for
      Returns:
      the port of this Worker
    • implementsProtocol

      public boolean implementsProtocol(String protocol)
      Description copied from interface: Worker
      Does this worker implement a given protocol?
      Specified by:
      implementsProtocol in interface Worker
      Parameters:
      protocol - the protocol to check this worker for
      Returns:
      whether the worker supports the requested protocol
    • getProtocols

      public List<WorkerProtocol> getProtocols()
      Description copied from interface: Worker
      The protocol that should be used to communicate with this worker. Values that are currently defined are "Enterprise", "EnterpriseWebsocket" or "Community", but the dispatcher itself does not care, it just passes it to the client
      Specified by:
      getProtocols in interface Worker
      Returns:
      the protocols that the worker implement
    • isRegistered

      public boolean isRegistered()
      Description copied from interface: KeepAliveWorker
      Returns true if this worker is registered.
      Specified by:
      isRegistered in interface KeepAliveWorker
    • setRegistered

      public void setRegistered()
      Description copied from interface: Worker
      Set that this worker is registered.
      Specified by:
      setRegistered in interface Worker
    • getPid

      public int getPid()
      Description copied from interface: Worker
      Returns the pid of this Worker
      Specified by:
      getPid in interface Worker
      Returns:
      the pid of this Worker
    • isFinished

      public boolean isFinished()
      Description copied from interface: KeepAliveWorker
      Returns the isFinished status of this Worker
      Specified by:
      isFinished in interface KeepAliveWorker
      Returns:
      the isFinished status of this Worker
    • getCompiledClassDirectory

      public File getCompiledClassDirectory()
      Description copied from interface: Worker
      Returns the compiledClassDirectory of this Worker
      Specified by:
      getCompiledClassDirectory in interface Worker
      Returns:
      the compiledClassDirectory of this Worker
    • getArtifactDirectory

      public File getArtifactDirectory()
      Description copied from interface: Worker
      Returns the artifactDirectory of this Worker
      Specified by:
      getArtifactDirectory in interface Worker
      Returns:
      the artifactDirectory of this Worker
    • getAuthToken

      public AuthToken getAuthToken()
      Description copied from interface: Worker
      Returns the auth token for this Worker
      Specified by:
      getAuthToken in interface Worker
    • getCancelledTimeNS

      public long getCancelledTimeNS()
      Description copied from interface: Worker
      Returns the cancelledTimeNS of this Worker
      Specified by:
      getCancelledTimeNS in interface Worker
      Returns:
      the cancelledTimeNS of this Worker
    • setCancelledTimeNS

      public boolean setCancelledTimeNS(long cancelledTimeNS)
      Description copied from interface: Worker
      Set the cancelledTimeNS for this worker
      Specified by:
      setCancelledTimeNS in interface Worker
      Parameters:
      cancelledTimeNS - the port for this worker
      Returns:
      true if the cancellation time was set, false if the worker was already cancelled
    • setTerminateRequestSent

      public boolean setTerminateRequestSent()
      Description copied from interface: Worker
      Set the terminateRequestSent for this worker
      Specified by:
      setTerminateRequestSent in interface Worker
      Returns:
      true if the termination request was set, false if the termination request sent field has already been set
    • isJvmDestroySent

      public boolean isJvmDestroySent()
      Description copied from interface: Worker
      Returns the isJvmDestroySent status of this Worker
      Specified by:
      isJvmDestroySent in interface Worker
      Returns:
      the isJvmDestroySent status of this Worker
    • setJvmDestroySent

      public void setJvmDestroySent(boolean jvmDestroySent)
      Description copied from interface: Worker
      Sets the jvmDestroySent status of this Worker
      Specified by:
      setJvmDestroySent in interface Worker
      Parameters:
      jvmDestroySent - status of this Worker
    • getProcessEventLogLogger

      public ProcessEventLogFormat2Logger getProcessEventLogLogger()
      Description copied from interface: Worker
      Returns the processEventLogLogger of this Worker
      Specified by:
      getProcessEventLogLogger in interface Worker
      Returns:
      the processEventLogLogger of this Worker
    • getDispatcherHostName

      public String getDispatcherHostName()
      Description copied from interface: Worker
      Returns the dispatcherHostName of this Worker
      Specified by:
      getDispatcherHostName in interface Worker
      Returns:
      the dispatcherHostName of this Worker
    • getDispatcherNameForDiscovery

      public String getDispatcherNameForDiscovery()
      Description copied from interface: Worker
      Returns the name of this dispatcher used by etcd for discovery
      Specified by:
      getDispatcherNameForDiscovery in interface Worker
      Returns:
      the discovery name for this dispatcher
    • getLatestErrorMessages

      public List<String> getLatestErrorMessages()
      Description copied from interface: Worker
      Returns the last few lines captured from the worker's syserr.
      Specified by:
      getLatestErrorMessages in interface Worker
      Returns:
      the last few lines from the worker's syserr
    • getWorkerHostname

      public String getWorkerHostname()
      Defaults to null, but allows K8S workers to specify a hostname for the worker, since each worker will have its own pod name.
      Specified by:
      getWorkerHostname in interface Worker
      Returns:
      The hostname of the worker.
    • getTimeToLiveExpiration

      public long getTimeToLiveExpiration()
      Description copied from interface: KeepAliveWorker
      Return the worker's TTL expiration (in millis since the epoch).
      Specified by:
      getTimeToLiveExpiration in interface KeepAliveWorker
      Returns:
      the maximum time that the worker has renewed it's TTL
    • setTimeToLive

      public void setTimeToLive(long ttl)
      Description copied from interface: KeepAliveWorker
      Set the time to live (in millis since the epoch).
      Specified by:
      setTimeToLive in interface KeepAliveWorker
    • getLastPostedStatus

      public DispatcherClientConstants.PostedWorkerStatus getLastPostedStatus()
      Description copied from interface: KeepAliveWorker
      Returns the last posted status for this Worker; Note it can be null if no status posted yet.
      Specified by:
      getLastPostedStatus in interface KeepAliveWorker
      Returns:
      the last posted status for this Worker
    • setLastPostedStatus

      public void setLastPostedStatus(DispatcherClientConstants.PostedWorkerStatus newLastPostedStatus)
      Description copied from interface: KeepAliveWorker
      Set the last posted status for this Worker
      Specified by:
      setLastPostedStatus in interface KeepAliveWorker
    • sleepFor

      protected void sleepFor(long millis)
    • getStarted

      public boolean getStarted()
      Description copied from interface: Worker
      Get if the worker has been completely started and is reachable. This is different from the worker being registered, which means the worker has phoned home that it is ready to accept connections.
      Specified by:
      getStarted in interface Worker
      Returns:
      true if the worker has been started
    • setStarted

      public void setStarted(boolean started)
      Description copied from interface: Worker
      Set if the worker has been completely started and is reachable.
      Specified by:
      setStarted in interface Worker
      Parameters:
      started - true if the worker has been started