diff options
Diffstat (limited to 'controller-api')
3 files changed, 20 insertions, 8 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java index cc10041992c..cb29d5854a0 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/model/ClusterMetrics.java @@ -1,7 +1,6 @@ // Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.application.v4.model; -import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -16,15 +15,16 @@ public class ClusterMetrics { public static final String DOCUMENT_COUNT = "documentCount"; public static final String FEED_LATENCY = "feedLatency"; public static final String QUERY_LATENCY = "queryLatency"; + public static final String FEEDING_BLOCKED = "feedingBlocked"; private final String clusterId; private final String clusterType; private final Map<String, Double> metrics; - public ClusterMetrics(String clusterId, String clusterType) { + public ClusterMetrics(String clusterId, String clusterType, Map<String, Double> metrics) { this.clusterId = clusterId; this.clusterType = clusterType; - this.metrics = new HashMap<>(); + this.metrics = Map.copyOf(metrics); } public String getClusterId() { @@ -55,9 +55,8 @@ public class ClusterMetrics { return Optional.ofNullable(metrics.get(QUERY_LATENCY)); } - public ClusterMetrics addMetric(String name, double value) { - metrics.put(name, value); - return this; + public Optional<Double> feedingBlocked() { + return Optional.ofNullable(metrics.get(FEEDING_BLOCKED)); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java index d356f5eb89f..07de259be2f 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Cluster.java @@ -107,16 +107,19 @@ public class Cluster { private final ClusterResources from, to; private final Instant at; + private final Optional<Instant> completion; - public ScalingEvent(ClusterResources from, ClusterResources to, Instant at) { + public ScalingEvent(ClusterResources from, ClusterResources to, Instant at, Optional<Instant> completion) { this.from = from; this.to = to; this.at = at; + this.completion = completion; } public ClusterResources from() { return from; } public ClusterResources to() { return to; } public Instant at() { return at; } + public Optional<Instant> completion() { return completion; } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java index b33a7436522..1ac24695afe 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/noderepository/ScalingEventData.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Cluster; import java.time.Instant; +import java.util.Optional; /** * @author bratseth @@ -24,8 +25,17 @@ public class ScalingEventData { @JsonProperty("at") public Long at; + @JsonProperty("completion") + public Long completion; + public Cluster.ScalingEvent toScalingEvent() { - return new Cluster.ScalingEvent(from.toClusterResources(), to.toClusterResources(), Instant.ofEpochMilli(at)); + return new Cluster.ScalingEvent(from.toClusterResources(), to.toClusterResources(), Instant.ofEpochMilli(at), + toOptionalInstant(completion)); + } + + private Optional<Instant> toOptionalInstant(Long epochMillis) { + if (epochMillis == null) return Optional.empty(); + return Optional.of(Instant.ofEpochMilli(epochMillis)); } } |