diff options
Diffstat (limited to 'service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthMonitor.java')
-rw-r--r-- | service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthMonitor.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthMonitor.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthMonitor.java new file mode 100644 index 00000000000..d37797c7be9 --- /dev/null +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthMonitor.java @@ -0,0 +1,33 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.service.health; + +import com.yahoo.vespa.applicationmodel.ServiceStatus; +import com.yahoo.vespa.service.executor.Cancellable; +import com.yahoo.vespa.service.executor.RunletExecutor; + +import java.time.Duration; + +/** + * Used to monitor the health of a single URL endpoint. + * + * @author hakon + */ +class StateV1HealthMonitor implements HealthMonitor { + private final StateV1HealthUpdater updater; + private final Cancellable periodicExecution; + + StateV1HealthMonitor(StateV1HealthUpdater updater, RunletExecutor executor, Duration delay) { + this.updater = updater; + this.periodicExecution = executor.scheduleWithFixedDelay(updater, delay); + } + + @Override + public ServiceStatus getStatus() { + return updater.getLatestHealthInfo().toServiceStatus(); + } + + @Override + public void close() { + periodicExecution.cancel(); + } +} |