diff options
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Cluster.java')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Cluster.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Cluster.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Cluster.java index 90133f7499e..c996daf588b 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Cluster.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Cluster.java @@ -3,9 +3,8 @@ package com.yahoo.vespa.hosted.provision.applications; import com.yahoo.config.provision.ClusterResources; import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.config.provision.NodeResources; -import com.yahoo.vespa.hosted.provision.lb.LoadBalancer; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -19,11 +18,15 @@ import java.util.Optional; */ public class Cluster { + public static final int maxScalingEvents = 15; + private final ClusterSpec.Id id; private final boolean exclusive; private final ClusterResources min, max; private final Optional<ClusterResources> suggested; private final Optional<ClusterResources> target; + + /** The maxScalingEvents last scaling events of this, sorted by increasing time (newest last) */ private final List<ScalingEvent> scalingEvents; private final String autoscalingStatus; @@ -45,7 +48,7 @@ public class Cluster { this.target = Optional.empty(); else this.target = targetResources; - this.scalingEvents = scalingEvents; + this.scalingEvents = List.copyOf(scalingEvents); this.autoscalingStatus = autoscalingStatus; } @@ -97,8 +100,10 @@ public class Cluster { } public Cluster with(ScalingEvent scalingEvent) { - // NOTE: We're just storing the latest scaling event so far - return new Cluster(id, exclusive, min, max, suggested, target, List.of(scalingEvent), autoscalingStatus); + List<ScalingEvent> scalingEvents = new ArrayList<>(this.scalingEvents); + scalingEvents.add(scalingEvent); + prune(scalingEvents); + return new Cluster(id, exclusive, min, max, suggested, target, scalingEvents, autoscalingStatus); } public Cluster withAutoscalingStatus(String autoscalingStatus) { @@ -120,4 +125,9 @@ public class Cluster { return "cluster '" + id + "'"; } + private void prune(List<ScalingEvent> scalingEvents) { + while (scalingEvents.size() > maxScalingEvents) + scalingEvents.remove(0); + } + } |