diff options
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java | 9 |
1 files changed, 9 insertions, 0 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(); } |