diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-06-04 16:02:05 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-06-04 16:02:05 +0200 |
commit | 18a5a0d9be2e9ffc29374a0b72aca8ef406c12f1 (patch) | |
tree | 6bf729ffebe9fd466e55614ebdb54cfe659bec6c /node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications | |
parent | 111177d05beb86d1fcb77267873f330a6e615797 (diff) |
More autoscaling status information
Diffstat (limited to 'node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications')
3 files changed, 75 insertions, 7 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Application.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Application.java index 5eb01b4fe72..c8d5e4361a5 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Application.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Application.java @@ -62,7 +62,7 @@ public class Application { public Application withCluster(ClusterSpec.Id id, boolean exclusive, ClusterResources min, ClusterResources max) { Cluster cluster = clusters.get(id); if (cluster == null) - cluster = new Cluster(id, exclusive, min, max, Optional.empty(), Optional.empty(), List.of(), ""); + cluster = new Cluster(id, exclusive, min, max, Optional.empty(), Optional.empty(), List.of(), AutoscalingStatus.empty()); else cluster = cluster.withConfiguration(exclusive, min, max); return with(cluster); diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/AutoscalingStatus.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/AutoscalingStatus.java new file mode 100644 index 00000000000..c40408c9109 --- /dev/null +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/AutoscalingStatus.java @@ -0,0 +1,69 @@ +package com.yahoo.vespa.hosted.provision.applications; + +import com.yahoo.vespa.hosted.provision.autoscale.Autoscaler; + +import java.util.Objects; + +/** + * The current autoscaling status of a cluster. + * A value object. + * + * @author bratseth + */ +public class AutoscalingStatus { + + public enum Status { + + /** No status is available: Aautoscaling is disabled, or a brand new application. */ + unavailable, + + /** Autoscaling is not taking any action at the moment due to recent changes or a lack of data */ + waiting, + + /** The cluster is ideally scaled to the current load */ + ideal, + + /** The cluster should be rescaled further, but no better configuration is allowed by the current limits */ + insufficient, + + /** Rescaling of this cluster has been scheduled */ + rescaling + + }; + + private final Status status; + private final String description; + + public AutoscalingStatus(Status status, String description) { + this.status = status; + this.description = description; + } + + public Status status() { return status; } + public String description() { return description; } + + public static AutoscalingStatus empty() { return new AutoscalingStatus(Status.unavailable, ""); } + + @Override + public boolean equals(Object o) { + if (o == this) return true; + if ( ! ( o instanceof AutoscalingStatus)) return false; + + AutoscalingStatus other = (AutoscalingStatus)o; + if ( other.status != this.status ) return false; + if ( ! other.description.equals(this.description) ) return false; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(status, description); + } + + @Override + public String toString() { + return "autoscaling status: " + status + + ( description.isEmpty() ? "" : " (" + description + ")"); + } + +} 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 59b70ff1ef0..d4bbe6adc1b 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 @@ -5,7 +5,6 @@ import com.yahoo.config.provision.ClusterResources; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.vespa.hosted.provision.autoscale.Autoscaler; -import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.List; @@ -31,7 +30,7 @@ public class Cluster { /** The maxScalingEvents last scaling events of this, sorted by increasing time (newest last) */ private final List<ScalingEvent> scalingEvents; - private final String autoscalingStatus; + private final AutoscalingStatus autoscalingStatus; public Cluster(ClusterSpec.Id id, boolean exclusive, @@ -40,7 +39,7 @@ public class Cluster { Optional<Suggestion> suggestedResources, Optional<ClusterResources> targetResources, List<ScalingEvent> scalingEvents, - String autoscalingStatus) { + AutoscalingStatus autoscalingStatus) { this.id = Objects.requireNonNull(id); this.exclusive = exclusive; this.min = Objects.requireNonNull(minResources); @@ -95,8 +94,8 @@ public class Cluster { return Optional.of(scalingEvents.get(scalingEvents.size() - 1)); } - /** The latest autoscaling status of this cluster, or empty (never null) if none */ - public String autoscalingStatus() { return autoscalingStatus; } + /** The latest autoscaling status of this cluster, or unknown (never null) if none */ + public AutoscalingStatus autoscalingStatus() { return autoscalingStatus; } public Cluster withConfiguration(boolean exclusive, ClusterResources min, ClusterResources max) { return new Cluster(id, exclusive, min, max, suggested, target, scalingEvents, autoscalingStatus); @@ -124,7 +123,7 @@ public class Cluster { return new Cluster(id, exclusive, min, max, suggested, target, scalingEvents, autoscalingStatus); } - public Cluster withAutoscalingStatus(String autoscalingStatus) { + public Cluster with(AutoscalingStatus autoscalingStatus) { if (autoscalingStatus.equals(this.autoscalingStatus)) return this; return new Cluster(id, exclusive, min, max, suggested, target, scalingEvents, autoscalingStatus); } |