summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-11-25 12:45:49 +0100
committerGitHub <noreply@github.com>2022-11-25 12:45:49 +0100
commitcc1a7c6d4e8d16ae578a882cf791c9da95d90949 (patch)
tree835bdb67f47c83ef25e0e5280a87431409c49682 /config-provisioning
parentad8906e7eca88ff9b8f7918e4913d2fd804d8a84 (diff)
parent5df29922963945c62fed8a19a5d231dbfb9c1cc7 (diff)
Merge pull request #24987 from vespa-engine/bratseth/explicit-zero
Bratseth/explicit zero
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java2
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java15
2 files changed, 13 insertions, 4 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 dd8d181e1df..e63750e0e11 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
@@ -26,7 +26,7 @@ public final class Capacity {
if (max.smallerThan(min))
throw new IllegalArgumentException("The max capacity must be larger than the min capacity, but got min " +
min + " and max " + max);
- if (!min.equals(max) && Stream.of(min, max).anyMatch(cr -> !cr.nodeResources().gpuResources().isDefault()))
+ if (!min.equals(max) && Stream.of(min, max).anyMatch(cr -> !cr.nodeResources().gpuResources().isZero()))
throw new IllegalArgumentException("Capacity range does not allow GPU, got min " + min + " and max " + max);
this.min = min;
this.max = max;
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java
index 92513636eaf..2f2310c3703 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java
@@ -123,7 +123,7 @@ public class NodeResources {
public record GpuResources(int count, double memoryGb) {
- private static final GpuResources none = new GpuResources(0, 0);
+ private static final GpuResources zero = new GpuResources(0, 0);
public GpuResources {
validate(memoryGb, "memory");
@@ -138,9 +138,14 @@ public class NodeResources {
this.memoryGb < other.memoryGb;
}
+ public boolean isZero() { return this.equals(zero); }
+
+ public static GpuResources zero() { return zero; }
+
public boolean isDefault() { return this.equals(getDefault()); }
- public static GpuResources getDefault() { return none; }
+ /** Returns zero gpu resources. */
+ public static GpuResources getDefault() { return zero; }
public GpuResources plus(GpuResources other) {
return new GpuResources(this.count + other.count, this.memoryGb + other.memoryGb);
@@ -274,7 +279,7 @@ public class NodeResources {
/** Returns this with all numbers set to 0 */
public NodeResources justNonNumbers() {
if (isUnspecified()) return unspecified();
- return withVcpu(0).withMemoryGb(0).withDiskGb(0).withBandwidthGbps(0).with(GpuResources.getDefault());
+ return withVcpu(0).withMemoryGb(0).withDiskGb(0).withBandwidthGbps(0).with(GpuResources.zero());
}
public NodeResources subtract(NodeResources other) {
@@ -499,6 +504,10 @@ public class NodeResources {
return value;
}
+ public boolean isZero() {
+ return this.equals(zero);
+ }
+
public static NodeResources zero() { return zero; }
}