Package com.smeup.kokos.sdk.health
Class FileProbeManager
java.lang.Object
com.smeup.kokos.sdk.health.FileProbeManager
File-based liveness/readiness probe for services that don't expose an HTTP API
(e.g. observer-manager). Periodically mirrors a
HealthState onto the
filesystem: the file is (re)written while healthy and deleted otherwise, so an
external prober (e.g. a container exec probe or livenessProbe.exec)
just needs to check for the file's existence/freshness — no port to expose.
Usage
HealthState health = new HealthState(true, false);
FileProbeManager.startPeriodicProbeTask(health); // uses /tmp/live and /tmp/ready
EventConsumerStartupContext<MyEvent> ctx = new EventConsumerStartupContext<>(...);
ctx.setHealthState(health);
EventConsumer.startConsumerWithRetry(ctx);
Container probe example (exec-based, e.g. Kubernetes or Docker HEALTH CHECK):
livenessProbe:
exec:
command: ["test", "-f", "/tmp/live"]
readinessProbe:
exec:
command: ["test", "-f", "/tmp/ready"]
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidStarts the probe task usingHealthState.global()and default files/interval.static voidstartPeriodicProbeTask(HealthState healthState) Starts the probe task for the givenHealthState, using default files (/tmp/live,/tmp/ready) and a 5s interval.static voidstartPeriodicProbeTask(HealthState healthState, Path liveFile, Path readyFile, long intervalSeconds) Starts the probe task, writing/deletingliveFileandreadyFileeveryintervalSecondsaccording tohealthState.static voidStops the probe task; the last written/deleted files are left as-is.
-
Method Details
-
startPeriodicProbeTask
public static void startPeriodicProbeTask()Starts the probe task usingHealthState.global()and default files/interval. -
startPeriodicProbeTask
Starts the probe task for the givenHealthState, using default files (/tmp/live,/tmp/ready) and a 5s interval. -
startPeriodicProbeTask
public static void startPeriodicProbeTask(HealthState healthState, Path liveFile, Path readyFile, long intervalSeconds) Starts the probe task, writing/deletingliveFileandreadyFileeveryintervalSecondsaccording tohealthState.- Parameters:
healthState- shared health state to mirror onto diskliveFile- path touched whileHealthState.isLive()is true, deleted otherwisereadyFile- path touched whileHealthState.isReady()is true, deleted otherwiseintervalSeconds- polling interval in seconds
-
stopPeriodicProbeTask
public static void stopPeriodicProbeTask()Stops the probe task; the last written/deleted files are left as-is.
-