diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-04-17 08:32:59 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-04-17 08:32:59 +0200 |
commit | ecac7190fdea2cd85eb52a1a0442ed14cdc7c41e (patch) | |
tree | fbe9b0cbee79d0106dc839b4254bbddd0860f7e8 /config-provisioning | |
parent | 29b53c9341892bd5afcff66befc4eb8f3d816f24 (diff) |
Fallback to deduce size again
Move cluster size validation to Capacity:
We may reason about illegal sizes but not request them.
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java | 9 | ||||
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java | 3 |
2 files changed, 9 insertions, 3 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 48b4e9d91bc..09ee25fb437 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 @@ -21,6 +21,8 @@ public final class Capacity { private final NodeType type; private Capacity(ClusterResources min, ClusterResources max, boolean required, boolean canFail, NodeType type) { + validate(min); + validate(max); if (max.smallerThan(min)) throw new IllegalArgumentException("The max capacity must be larger than the min capacity, but got min " + min + " and max " + max); @@ -31,6 +33,13 @@ public final class Capacity { this.type = type; } + private static void validate(ClusterResources resources) { + if (resources.nodes() == 0 && resources.groups() == 0) return; // unspecified + if (resources.nodes() % resources.groups() != 0) + throw new IllegalArgumentException("The number of nodes (" + resources.nodes() + + ") must be divisible by the number of groups (" + resources.groups() + ")"); + } + /** Returns the number of nodes requested */ @Deprecated // TODO: Remove after April 2020 public int nodeCount() { return min.nodes(); } 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 87b5133d4eb..11ae0845fb0 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 @@ -20,9 +20,6 @@ public class ClusterResources { private final NodeResources nodeResources; public ClusterResources(int nodes, int groups, NodeResources nodeResources) { - if (nodes > 0 && groups > 0 && nodes % groups != 0) - throw new IllegalArgumentException("The number of nodes (" + nodes + - ") must be divisible by the number of groups (" + groups + ")"); this.nodes = nodes; this.groups = groups; this.nodeResources = Objects.requireNonNull(nodeResources); |