Class WorkerLeaseHandler
java.lang.Object
com.fishlib.io.sched.Job
com.fishlib.io.sched.TimedJob
com.illumon.iris.db.tables.remotequery.keepalive.WorkerLeaseHandler
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
public class WorkerLeaseHandler
extends com.fishlib.io.sched.TimedJob
A WorkerLeaseHandler manages an etcd lease that holds key-values that indicate liveness to workers.
This should be used in concert with a WorkerTtlCheckJob
and a AbstractWorkerStatusServlet
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Callback invoked when the lease handler must recreate leases (because our existing lease was broken). -
Constructor Summary
ConstructorsConstructorDescriptionWorkerLeaseHandler
(com.fishlib.io.logger.Logger log, String dispatcherNameForDiscovery, String dispatcherUrl, int leaseTtlSeconds, int leaseRenewSeconds, int leaseRenewRetryDelaySeconds, WorkerLeaseHandler.LeaseRecreationCallback leaseRecreationCallback) Manages etcd lease for workers that use this process to control their lifetime. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteWorkerStatus
(String processInfoId) void
boolean
setWorkerStatus
(String processInfoId, String status) boolean
setWorkerStatus
(String processInfoId, String status, boolean fromRecreate) void
timedOut()
Methods inherited from class com.fishlib.io.sched.TimedJob
append, cancelled, invoke
-
Constructor Details
-
WorkerLeaseHandler
public WorkerLeaseHandler(com.fishlib.io.logger.Logger log, String dispatcherNameForDiscovery, String dispatcherUrl, int leaseTtlSeconds, int leaseRenewSeconds, int leaseRenewRetryDelaySeconds, WorkerLeaseHandler.LeaseRecreationCallback leaseRecreationCallback) throws IOException, ExecutionException, InterruptedException, TimeoutException Manages etcd lease for workers that use this process to control their lifetime.- Parameters:
log
- the logdispatcherNameForDiscovery
- the name of this dispatcherdispatcherUrl
- the URL that clients connect to for this dispatcherleaseTtlSeconds
- the time-to-live of our etcd leaseleaseRenewSeconds
- the number of seconds between etcd lease renewalsleaseRenewRetryDelaySeconds
- do not retry a renewal until this many seconds after a failureleaseRecreationCallback
- the lease recreation callback- Throws:
IOException
- thrown by jetcd clientExecutionException
- thrown by jetcd clientInterruptedException
- thrown by jetcd clientTimeoutException
- thrown by jetcd client
-
-
Method Details
-
timedOut
public void timedOut()- Specified by:
timedOut
in classcom.fishlib.io.sched.Job
-
setWorkerStatus
-
setWorkerStatus
-
deleteWorkerStatus
-
revokeLease
public void revokeLease()
-