aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-11-25 12:09:37 +0100
committerJon Bratseth <bratseth@gmail.com>2022-11-25 12:09:37 +0100
commit4193a9cbb4a74541a8b3be9d0cf45a9239e46a2b (patch)
tree3f3c343366d71615b41c7b5a640c97bfb95ef093 /config-provisioning
parentf6b2f73bb7f7781acc41d1ce2543442e1d92b6ba (diff)
Explicit zero
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java15
1 files changed, 12 insertions, 3 deletions
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; }
}