diff options
Diffstat (limited to 'config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java')
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java | 18 |
1 files changed, 16 insertions, 2 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 d1fd409fc93..a431dd61b0d 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 @@ -213,6 +213,7 @@ public class NodeResources { public boolean vcpuIsUnspecified() { return vcpu == 0; } public boolean memoryGbIsUnspecified() { return memoryGb == 0; } public boolean diskGbIsUnspecified() { return diskGb == 0; } + public boolean bandwidthGbpsIsUnspecified() { return bandwidthGbps == 0; } /** Returns the standard cost of these resources, in dollars per hour */ public double cost() { @@ -267,6 +268,19 @@ public class NodeResources { return new NodeResources(vcpu, memoryGb, diskGb, bandwidthGbps, diskSpeed, storageType, architecture, gpuResources); } + public NodeResources withUnspecifiedNumbersFrom(NodeResources fullySpecified) { + var resources = this; + if (resources.vcpuIsUnspecified()) + resources = resources.withVcpu(fullySpecified.vcpu()); + if (resources.memoryGbIsUnspecified()) + resources = resources.withMemoryGb(fullySpecified.memoryGb()); + if (resources.diskGbIsUnspecified()) + resources = resources.withDiskGb(fullySpecified.diskGb()); + if (resources.bandwidthGbpsIsUnspecified()) + resources = resources.withBandwidthGbps(fullySpecified.bandwidthGbps()); + return resources; + } + /** Returns this with disk speed, storage type and architecture set to any */ public NodeResources justNumbers() { if (isUnspecified()) return unspecified(); @@ -362,7 +376,7 @@ public class NodeResources { appendDouble(sb, vcpu); sb.append(", memory: "); appendDouble(sb, memoryGb); - sb.append(" Gb, disk "); + sb.append(" Gb, disk: "); appendDouble(sb, diskGb); sb.append(" Gb"); if (bandwidthGbps > 0) { @@ -461,7 +475,7 @@ public class NodeResources { throw new IllegalStateException("Cannot perform this on unspecified resources"); } - // Returns squared euclidean distance of the relevant numerical values of two node resources + // Returns squared Euclidean distance of the relevant numerical values of two node resources public double distanceTo(NodeResources other) { if ( ! this.diskSpeed().compatibleWith(other.diskSpeed())) return Double.MAX_VALUE; if ( ! this.storageType().compatibleWith(other.storageType())) return Double.MAX_VALUE; |