diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-11-21 13:50:49 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-11-21 13:50:49 +0100 |
commit | e5aaf8bf8672faf972ab67eaab0a72521622f6e4 (patch) | |
tree | 1ac9413d700c66b3fa81d81dfca42d672972a3fe /config-provisioning | |
parent | df6e6ef8cd7a84340bad00d0bc450386e4d56edb (diff) |
Support resizing check with GPU resources
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java | 19 |
1 files changed, 12 insertions, 7 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 7b1eb945247..4071fdf4c2f 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 @@ -143,6 +143,14 @@ public class NodeResources { public static GpuResources getDefault() { return none; } + public GpuResources plus(GpuResources other) { + return new GpuResources(this.count + other.count, this.memoryGb + other.memoryGb); + } + + public GpuResources minus(GpuResources other) { + return new GpuResources(this.count - other.count, this.memoryGb - other.memoryGb); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -155,7 +163,6 @@ public class NodeResources { public int hashCode() { return Objects.hash(count, memoryGb); } - } private final double vcpu; @@ -259,7 +266,7 @@ public class NodeResources { return new NodeResources(vcpu, memoryGb, diskGb, bandwidthGbps, diskSpeed, storageType, architecture, gpuResources); } - /** Returns this with disk speed and storage type set to any */ + /** Returns this with disk speed, storage type and architecture set to any */ public NodeResources justNumbers() { if (isUnspecified()) return unspecified(); return with(NodeResources.DiskSpeed.any).with(StorageType.any).with(Architecture.any); @@ -268,7 +275,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); + return withVcpu(0).withMemoryGb(0).withDiskGb(0).withBandwidthGbps(0).with(GpuResources.getDefault()); } public NodeResources subtract(NodeResources other) { @@ -283,7 +290,7 @@ public class NodeResources { this.diskSpeed.combineWith(other.diskSpeed), this.storageType.combineWith(other.storageType), this.architecture.combineWith(other.architecture), - gpuResources); + this.gpuResources.minus(other.gpuResources)); } public NodeResources add(NodeResources other) { @@ -297,7 +304,7 @@ public class NodeResources { this.diskSpeed.combineWith(other.diskSpeed), this.storageType.combineWith(other.storageType), this.architecture.combineWith(other.architecture), - gpuResources); + this.gpuResources.plus(other.gpuResources)); } private boolean isInterchangeableWith(NodeResources other) { @@ -309,8 +316,6 @@ public class NodeResources { return false; if (this.architecture != Architecture.any && other.architecture != Architecture.any && this.architecture != other.architecture) return false; - if ( ! this.gpuResources.equals(other.gpuResources)) - return false; return true; } |