diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-01-02 16:55:03 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-01-02 16:55:03 +0100 |
commit | 20a6b5041b179a382a90ca37382a0b6ba3f963f7 (patch) | |
tree | 08997145ac9497279caacf295b0b09261cdce1de /node-repository/src/main/java/com/yahoo | |
parent | e5d908c70f1063b05c965e989af1da8c4cb393b1 (diff) |
Output load in target/suggested block
Diffstat (limited to 'node-repository/src/main/java/com/yahoo')
2 files changed, 20 insertions, 18 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaling.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaling.java index 579f9c2514f..2989d675daa 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaling.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/Autoscaling.java @@ -30,15 +30,15 @@ public class Autoscaling { this.ideal = ideal; } + public Status status() { return status; } + + public String description() { return description; } + /** Returns the resource target of this, or empty if none (meaning keep the current allocation). */ public Optional<ClusterResources> resources() { return resources; } - public Status status() { return status; } - - public String description() { return description; } - /** Returns the time this was decided. */ public Instant at() { return at; } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationSerializer.java index eac49a705b1..cb927c72eb5 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationSerializer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/ApplicationSerializer.java @@ -9,6 +9,7 @@ import com.yahoo.vespa.hosted.provision.NodeRepository; import com.yahoo.vespa.hosted.provision.applications.Application; import com.yahoo.vespa.hosted.provision.applications.Cluster; import com.yahoo.vespa.hosted.provision.applications.ScalingEvent; +import com.yahoo.vespa.hosted.provision.autoscale.Autoscaling; import com.yahoo.vespa.hosted.provision.autoscale.Limits; import com.yahoo.vespa.hosted.provision.autoscale.Load; @@ -63,30 +64,31 @@ public class ApplicationSerializer { toSlime(limits.max(), clusterObject.setObject("max")); toSlime(currentResources, clusterObject.setObject("current")); if (cluster.shouldSuggestResources(currentResources)) - cluster.suggested().resources().ifPresent(suggested -> toSlime(suggested, clusterObject.setObject("suggested"))); - cluster.target().resources().ifPresent(target -> toSlime(target, clusterObject.setObject("target"))); - clusterUtilizationToSlime(cluster.target().ideal(), cluster.target().peak(), clusterObject.setObject("utilization")); + toSlime(cluster.suggested(), clusterObject.setObject("suggested")); + toSlime(cluster.target(), clusterObject.setObject("target")); scalingEventsToSlime(cluster.scalingEvents(), clusterObject.setArray("scalingEvents")); - clusterObject.setString("autoscalingStatusCode", cluster.target().status().name()); - clusterObject.setString("autoscalingStatus", cluster.target().description()); clusterObject.setLong("scalingDuration", cluster.scalingDuration(nodes.clusterSpec()).toMillis()); } + private static void toSlime(Autoscaling autoscaling, Cursor autoscalingObject) { + autoscalingObject.setString("status", autoscaling.status().name()); + autoscalingObject.setString("description", autoscaling.description()); + autoscaling.resources().ifPresent(resources -> toSlime(resources, autoscalingObject.setObject("resources"))); + autoscalingObject.setLong("at", autoscaling.at().toEpochMilli()); + toSlime(autoscaling.peak(), autoscalingObject.setObject("peak")); + toSlime(autoscaling.ideal(), autoscalingObject.setObject("ideal")); + } + private static void toSlime(ClusterResources resources, Cursor clusterResourcesObject) { clusterResourcesObject.setLong("nodes", resources.nodes()); clusterResourcesObject.setLong("groups", resources.groups()); NodeResourcesSerializer.toSlime(resources.nodeResources(), clusterResourcesObject.setObject("resources")); } - private static void clusterUtilizationToSlime(Load idealLoad, Load peakLoad, Cursor utilizationObject) { - utilizationObject.setDouble("idealCpu", idealLoad.cpu()); - utilizationObject.setDouble("peakCpu", peakLoad.cpu()); - - utilizationObject.setDouble("idealMemory", idealLoad.memory()); - utilizationObject.setDouble("peakMemory", peakLoad.memory()); - - utilizationObject.setDouble("idealDisk", idealLoad.disk()); - utilizationObject.setDouble("peakDisk", peakLoad.disk()); + private static void toSlime(Load load, Cursor utilizationObject) { + utilizationObject.setDouble("cpu", load.cpu()); + utilizationObject.setDouble("memory", load.memory()); + utilizationObject.setDouble("disk", load.disk()); } private static void scalingEventsToSlime(List<ScalingEvent> scalingEvents, Cursor scalingEventsArray) { |