diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-09-18 17:12:52 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-09-18 17:12:52 +0200 |
commit | d300efc1d61d6405efe12d296c9ad09333b9d9c7 (patch) | |
tree | 64eabc1950efa144a5bfda72828b3710fd07eec5 /service-monitor | |
parent | 8ef29392f487ec917c597635a27b82f9a7d88342 (diff) |
Log when config server changes health
Diffstat (limited to 'service-monitor')
-rw-r--r-- | service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthUpdater.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthUpdater.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthUpdater.java index 985685ebb8d..5813e2cef39 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthUpdater.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthUpdater.java @@ -8,11 +8,18 @@ import java.net.URL; import java.time.Duration; import java.time.Instant; import java.util.Optional; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author hakonhall */ class StateV1HealthUpdater implements HealthUpdater { + private static final Logger logger = Logger.getLogger(StateV1HealthUpdater.class.getName()); + + private static final Pattern CONFIG_SERVER_ENDPOINT_PATTERN = Pattern.compile("^http://(cfg[0-9]+)\\."); + private final String endpoint; private final StateV1HealthClient healthClient; @@ -46,8 +53,18 @@ class StateV1HealthUpdater implements HealthUpdater { } ServiceStatus newServiceStatus = healthInfo.isHealthy() ? ServiceStatus.UP : ServiceStatus.DOWN; - Optional<Instant> newSince = newServiceStatus == serviceStatusInfo.serviceStatus() ? - serviceStatusInfo.since() : Optional.of(now); + + final Optional<Instant> newSince; + if (newServiceStatus == serviceStatusInfo.serviceStatus()) { + newSince = serviceStatusInfo.since(); + } else { + newSince = Optional.of(now); + + Matcher matcher = CONFIG_SERVER_ENDPOINT_PATTERN.matcher(endpoint); + if (matcher.find()) { + logger.info("New health status for " + matcher.group(1) + ": " + healthInfo.toString()); + } + } serviceStatusInfo = new ServiceStatusInfo(newServiceStatus, newSince, Optional.of(now), healthInfo.getErrorDescription(), Optional.of(endpoint)); |