diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2021-04-26 17:04:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 17:04:51 +0200 |
commit | c742485abd7ebaa5d325a6b59c9bffc393b907e6 (patch) | |
tree | 8f9c1aa6069fe78c7630bd8e627a9806fd4c00ee /controller-api | |
parent | 6ab4761b814b9b369a60b1f2e059361f8da8e8e4 (diff) | |
parent | 75c0efa70804490a16030b2ab07fa7290bdb6fc6 (diff) |
Merge pull request #17604 from vespa-engine/bratseth/completion
Add completion to scaling events in rest API's
Diffstat (limited to 'controller-api')
2 files changed, 15 insertions, 2 deletions
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)); } } |