aboutsummaryrefslogtreecommitdiffstats
path: root/application-model
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2019-01-25 09:27:12 +0100
committerHåkon Hallingstad <hakon@oath.com>2019-01-25 09:27:12 +0100
commitcd7f0447817eaf21898f172bdc2a4fc8bb721d1a (patch)
treedd02bf7436bbf07671cd4b2f115eb9ce943b7ce2 /application-model
parentee29f449256f4d9d21abe8e1c461399b2cb303ca (diff)
Metadata about /state/v1/health status
The service monitor uses /state/v1/health to monitor config servers and the host admins (but not yet tenant host admins). This commit adds some metadata about the status of a service: - The time the status was last checked - The time the status changed to the current This can be used to e.g. make more intelligent decisions in the Orchestrator, e.g. only allowing a service to suspend if it has been DOWN longer than X seconds (to avoid spurious DOWN to break redundancy and uptime guarantees).
Diffstat (limited to 'application-model')
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java25
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java90
2 files changed, 108 insertions, 7 deletions
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java
index 80178f79bb1..b4fce878b0d 100644
--- a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceInstance.java
@@ -14,13 +14,17 @@ public class ServiceInstance {
private final ConfigId configId;
private final HostName hostName;
- private final ServiceStatus serviceStatus;
+ private final ServiceStatusInfo serviceStatusInfo;
private Optional<ServiceCluster> serviceCluster = Optional.empty();
public ServiceInstance(ConfigId configId, HostName hostName, ServiceStatus serviceStatus) {
+ this(configId, hostName, new ServiceStatusInfo(serviceStatus));
+ }
+
+ public ServiceInstance(ConfigId configId, HostName hostName, ServiceStatusInfo serviceStatusInfo) {
this.configId = configId;
this.hostName = hostName;
- this.serviceStatus = serviceStatus;
+ this.serviceStatusInfo = serviceStatusInfo;
}
@JsonProperty("configId")
@@ -33,9 +37,13 @@ public class ServiceInstance {
return hostName;
}
- @JsonProperty("serviceStatus")
public ServiceStatus serviceStatus() {
- return serviceStatus;
+ return serviceStatusInfo.serviceStatus();
+ }
+
+ @JsonProperty("serviceStatusInfo")
+ public ServiceStatusInfo serviceStatusInfo() {
+ return serviceStatusInfo;
}
@JsonIgnore
@@ -50,10 +58,11 @@ public class ServiceInstance {
@Override
public String toString() {
+ // serviceCluster omitted to avoid recursion
return "ServiceInstance{" +
"configId=" + configId +
", hostName=" + hostName +
- ", serviceStatus=" + serviceStatus +
+ ", serviceStatus=" + serviceStatusInfo +
'}';
}
@@ -62,13 +71,15 @@ public class ServiceInstance {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ServiceInstance that = (ServiceInstance) o;
+ // serviceCluster omitted to avoid recursion
return Objects.equals(configId, that.configId) &&
Objects.equals(hostName, that.hostName) &&
- serviceStatus == that.serviceStatus;
+ serviceStatusInfo == that.serviceStatusInfo;
}
@Override
public int hashCode() {
- return Objects.hash(configId, hostName, serviceStatus);
+ // serviceCluster omitted to avoid recursion
+ return Objects.hash(configId, hostName, serviceStatusInfo);
}
}
diff --git a/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java
new file mode 100644
index 00000000000..da2b1bb6ad8
--- /dev/null
+++ b/application-model/src/main/java/com/yahoo/vespa/applicationmodel/ServiceStatusInfo.java
@@ -0,0 +1,90 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.applicationmodel;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.time.Instant;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * @author hakonhall
+ */
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+public class ServiceStatusInfo {
+ private final ServiceStatus status;
+ private final Optional<Instant> since;
+ private final Optional<Instant> lastChecked;
+ private final Optional<String> error;
+
+ public ServiceStatusInfo(ServiceStatus status) {
+ this(status, Optional.empty(), Optional.empty(), Optional.empty());
+ }
+
+ public ServiceStatusInfo(ServiceStatus status, Instant since, Instant lastChecked, Optional<String> error) {
+ this(status, Optional.of(since), Optional.of(lastChecked), error);
+ }
+
+ public ServiceStatusInfo(ServiceStatus status, Optional<Instant> since, Optional<Instant> lastChecked,
+ Optional<String> error) {
+ this.status = status;
+ this.since = since;
+ this.lastChecked = lastChecked;
+ this.error = error;
+ }
+
+ @JsonProperty("serviceStatus")
+ public ServiceStatus serviceStatus() {
+ return status;
+ }
+
+ /** The current service status was first seen at this time, and has since stayed constant. */
+ public Optional<Instant> since() {
+ return since;
+ }
+
+ @JsonProperty("since")
+ public Instant sinceOrNull() {
+ return since.orElse(null);
+ }
+
+ /** The last time the status was checked. */
+ public Optional<Instant> lastChecked() {
+ return lastChecked;
+ }
+
+ @JsonProperty("lastChecked")
+ public Instant lastCheckedOrNull() {
+ return lastChecked.orElse(null);
+ }
+
+ @JsonProperty("error")
+ public String errorOrNull() {
+ return error.orElse(null);
+ }
+
+ @Override
+ public String toString() {
+ return "ServiceStatusInfo{" +
+ "status=" + status +
+ ", since=" + since +
+ ", lastChecked=" + lastChecked +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ServiceStatusInfo that = (ServiceStatusInfo) o;
+ return status == that.status &&
+ Objects.equals(since, that.since) &&
+ Objects.equals(lastChecked, that.lastChecked);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(status, since, lastChecked);
+ }
+}