summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-11-17 13:26:36 +0100
committerJon Bratseth <bratseth@gmail.com>2022-11-17 13:26:36 +0100
commitf0b5b4aa5142c3f9e36ecb18b28a0aa2535c72bc (patch)
tree59a05cce5099356d2fdebfd3ebac59c19c256187 /config-provisioning
parent22413c3ad0c0d27f8af4df8bd0c80019d90a0fbe (diff)
Mostly test with AWS setup
- AWS adds the complexity of advertised vs. real which we want to test as much as possible. - Testing with host sharing as that provuces accurate resource numbers.
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java33
1 files changed, 29 insertions, 4 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 25771f1906b..780f989e39f 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
@@ -259,8 +259,7 @@ public class NodeResources {
@Override
public boolean equals(Object o) {
if (o == this) return true;
- if ( ! (o instanceof NodeResources)) return false;
- NodeResources other = (NodeResources)o;
+ if ( ! (o instanceof NodeResources other)) return false;
if ( ! equal(this.vcpu, other.vcpu)) return false;
if ( ! equal(this.memoryGb, other.memoryGb)) return false;
if ( ! equal(this.diskGb, other.diskGb)) return false;
@@ -333,8 +332,34 @@ public class NodeResources {
return true;
}
- /** Returns true if all the resources of this are the same as or compatible with the given resources */
- public boolean compatibleWith(NodeResources other) {
+ /**
+ * Returns true if all the resources of this are the same as or compatible with the requested resources:
+ * - Equal numbers only where request implies it (i.e not for disk if storage is any/remote, and not for bandwith
+ * where we don't enforce constraints),
+ * - Compatible non-numbers.
+ */
+ public boolean compatibleWith(NodeResources requested) {
+ if ( ! equal(this.vcpu, requested.vcpu)) return false;
+ if ( ! equal(this.memoryGb, requested.memoryGb)) return false;
+ if (requested.storageType == StorageType.local) {
+ if ( ! equal(this.diskGb, requested.diskGb)) return false;
+ }
+ else {
+ if (this.diskGb < requested.diskGb) return false;
+ }
+ if ( ! this.diskSpeed.compatibleWith(requested.diskSpeed)) return false;
+ if ( ! this.storageType.compatibleWith(requested.storageType)) return false;
+ if ( ! this.architecture.compatibleWith(requested.architecture)) return false;
+
+ return true;
+ }
+
+ /**
+ * Returns true if all the resources of this are the same as or compatible with the given resources:
+ * - Equal numbers.
+ * - Compatible non-numbers.
+ */
+ public boolean equalsWhereSpecified(NodeResources other) {
if ( ! equal(this.vcpu, other.vcpu)) return false;
if ( ! equal(this.memoryGb, other.memoryGb)) return false;
if ( ! equal(this.diskGb, other.diskGb)) return false;