diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-01-21 17:50:10 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-01-21 17:50:10 +0100 |
commit | 7a6af9caa065b3ab63b094d78b7347d7df6bea0f (patch) | |
tree | 48e80650a9cd88016ff8e618d85d727a28f3542c /config-provisioning/src/main | |
parent | 00d86602a88c66486c8f4c68a1c8bdff096c7273 (diff) |
Support a group size constraint in content clusters
Diffstat (limited to 'config-provisioning/src/main')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java | 36 | ||||
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java | 5 |
2 files changed, 30 insertions, 11 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java index e63750e0e11..993ab686675 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.provision; +import com.yahoo.collections.IntRange; + import java.util.Objects; import java.util.Optional; import java.util.stream.Stream; @@ -15,12 +17,19 @@ public final class Capacity { /** Resources should stay between these values, inclusive */ private final ClusterResources min, max; + private final IntRange groupSize; private final boolean required; private final boolean canFail; private final NodeType type; private final Optional<CloudAccount> cloudAccount; - private Capacity(ClusterResources min, ClusterResources max, boolean required, boolean canFail, NodeType type, Optional<CloudAccount> cloudAccount) { + private Capacity(ClusterResources min, + ClusterResources max, + IntRange groupSize, + boolean required, + boolean canFail, + NodeType type, + Optional<CloudAccount> cloudAccount) { validate(min); validate(max); if (max.smallerThan(min)) @@ -30,6 +39,7 @@ public final class Capacity { throw new IllegalArgumentException("Capacity range does not allow GPU, got min " + min + " and max " + max); this.min = min; this.max = max; + this.groupSize = groupSize; this.required = required; this.canFail = canFail; this.type = type; @@ -45,6 +55,7 @@ public final class Capacity { public ClusterResources minResources() { return min; } public ClusterResources maxResources() { return max; } + public IntRange groupSize() { return groupSize; } /** Returns whether the requested number of nodes must be met exactly for a request for this to succeed */ public boolean isRequired() { return required; } @@ -69,7 +80,11 @@ public final class Capacity { } public Capacity withLimits(ClusterResources min, ClusterResources max) { - return new Capacity(min, max, required, canFail, type, cloudAccount); + return withLimits(min, max, IntRange.empty()); + } + + public Capacity withLimits(ClusterResources min, ClusterResources max, IntRange groupSize) { + return new Capacity(min, max, groupSize, required, canFail, type, cloudAccount); } @Override @@ -85,29 +100,34 @@ public final class Capacity { /** Create a non-required, failable capacity request */ public static Capacity from(ClusterResources min, ClusterResources max) { - return from(min, max, false, true); + return from(min, max, IntRange.empty(), false, true, Optional.empty()); } public static Capacity from(ClusterResources resources, boolean required, boolean canFail) { return from(resources, required, canFail, NodeType.tenant); } - // TODO(mpolden): Remove when config models < 7.590 are gone + // TODO: Remove after February 2023 public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail) { - return from(min, max, required, canFail, Optional.empty()); + return new Capacity(min, max, IntRange.empty(), required, canFail, NodeType.tenant, Optional.empty()); } + // TODO: Remove after February 2023 public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) { - return new Capacity(min, max, required, canFail, NodeType.tenant, cloudAccount); + return new Capacity(min, max, IntRange.empty(), required, canFail, NodeType.tenant, cloudAccount); + } + + public static Capacity from(ClusterResources min, ClusterResources max, IntRange groupSize, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) { + return new Capacity(min, max, groupSize, required, canFail, NodeType.tenant, cloudAccount); } /** Creates this from a node type */ public static Capacity fromRequiredNodeType(NodeType type) { - return from(new ClusterResources(0, 0, NodeResources.unspecified()), true, false, type); + return from(new ClusterResources(0, 1, NodeResources.unspecified()), true, false, type); } private static Capacity from(ClusterResources resources, boolean required, boolean canFail, NodeType type) { - return new Capacity(resources, resources, required, canFail, type, Optional.empty()); + return new Capacity(resources, resources, IntRange.empty(), required, canFail, type, Optional.empty()); } } diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java index 9938823768b..5511a9ed1ed 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java @@ -21,7 +21,7 @@ public class ClusterResources { public ClusterResources(int nodes, int groups, NodeResources nodeResources) { this.nodes = nodes; - this.groups = groups; + this.groups = groups == 0 ? 1 : groups; // TODO: Throw on groups == 0 after February 2023 this.nodeResources = Objects.requireNonNull(nodeResources); } @@ -73,9 +73,8 @@ public class ClusterResources { @Override public boolean equals(Object o) { if (o == this) return true; - if ( ! (o instanceof ClusterResources)) return false; + if ( ! (o instanceof ClusterResources other)) return false; - ClusterResources other = (ClusterResources)o; if (other.nodes != this.nodes) return false; if (other.groups != this.groups) return false; if ( ! other.nodeResources.equals(this.nodeResources)) return false; |