diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2023-08-15 22:10:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 22:10:36 +0200 |
commit | 2fc7e4ee6646f29e398eef7f46af3454f32c992d (patch) | |
tree | 82319ae2c3ec11fb94f0ff0b9f1776aadd035f72 /node-repository/src/main/java/com/yahoo/vespa/hosted/provision/applications/Cluster.java | |
parent | 2ae55dbfddc73cfff8619b1735f52895afe1be9e (diff) | |
parent | 66ff658df11a001c0397db6756da0d3be2da905d (diff) |
Merge pull request #28056 from vespa-engine/bratseth/consider-reallocation-costv8.212.18
Bratseth/consider reallocation cost
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 | 10 |
1 files changed, 10 insertions, 0 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 1ca81df824b..796bc2eeb92 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 @@ -208,6 +208,16 @@ public class Cluster { return minimum(ClusterModel.minScalingDuration(clusterSpec), totalDuration.dividedBy(completedEventCount)); } + /** The predicted time this cluster will stay in each resource configuration (including the scaling duration). */ + public Duration allocationDuration(ClusterSpec clusterSpec) { + if (scalingEvents.size() < 2) return Duration.ofHours(12); // Default + + long totalDurationMs = 0; + for (int i = 1; i < scalingEvents().size(); i++) + totalDurationMs += scalingEvents().get(i).at().toEpochMilli() - scalingEvents().get(i - 1).at().toEpochMilli(); + return Duration.ofMillis(totalDurationMs / (scalingEvents.size() - 1)); + } + private static Duration minimum(Duration smallestAllowed, Duration duration) { if (duration.minus(smallestAllowed).isNegative()) return smallestAllowed; |