summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-11-14 20:34:26 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2019-11-14 20:34:26 +0100
commit61050a1678c5e2da424f6e8d21d5fa4b63fe114f (patch)
tree68ab9c8033da2529aabb3f9dddc7c5aacd56dcc1 /config-provisioning
parent150599b247afe2a47d917dcf973849cc3451b9ac (diff)
Move compatible check to enums
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/abi-spec.json2
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java12
2 files changed, 12 insertions, 2 deletions
diff --git a/config-provisioning/abi-spec.json b/config-provisioning/abi-spec.json
index 61cbc7da52d..4c1e6e3e08a 100644
--- a/config-provisioning/abi-spec.json
+++ b/config-provisioning/abi-spec.json
@@ -592,6 +592,7 @@
"public static com.yahoo.config.provision.NodeResources$DiskSpeed[] values()",
"public static com.yahoo.config.provision.NodeResources$DiskSpeed valueOf(java.lang.String)",
"public static int compare(com.yahoo.config.provision.NodeResources$DiskSpeed, com.yahoo.config.provision.NodeResources$DiskSpeed)",
+ "public boolean compatibleWith(com.yahoo.config.provision.NodeResources$DiskSpeed)",
"public boolean isDefault()",
"public static com.yahoo.config.provision.NodeResources$DiskSpeed getDefault()"
],
@@ -613,6 +614,7 @@
"public static com.yahoo.config.provision.NodeResources$StorageType[] values()",
"public static com.yahoo.config.provision.NodeResources$StorageType valueOf(java.lang.String)",
"public static int compare(com.yahoo.config.provision.NodeResources$StorageType, com.yahoo.config.provision.NodeResources$StorageType)",
+ "public boolean compatibleWith(com.yahoo.config.provision.NodeResources$StorageType)",
"public boolean isDefault()",
"public static com.yahoo.config.provision.NodeResources$StorageType getDefault()"
],
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 7769060dc60..ce3dd579d2f 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
@@ -29,6 +29,10 @@ public class NodeResources {
return 0;
}
+ public boolean compatibleWith(DiskSpeed other) {
+ return this == any || other == any || other == this;
+ }
+
private DiskSpeed combineWith(DiskSpeed other) {
if (this == any) return other;
if (other == any) return this;
@@ -60,6 +64,10 @@ public class NodeResources {
return 0;
}
+ public boolean compatibleWith(StorageType other) {
+ return this == any || other == any || other == this;
+ }
+
private StorageType combineWith(StorageType other) {
if (this == any) return other;
if (other == any) return this;
@@ -218,8 +226,8 @@ public class NodeResources {
if (this.memoryGb != other.memoryGb) return false;
if (this.diskGb != other.diskGb) return false;
if (this.bandwidthGbps != other.bandwidthGbps) return false;
- if (other.diskSpeed != DiskSpeed.any && other.diskSpeed != this.diskSpeed) return false;
- if (other.storageType != StorageType.any && other.storageType != this.storageType) return false;
+ if ( ! this.diskSpeed.compatibleWith(other.diskSpeed)) return false;
+ if ( ! this.storageType.compatibleWith(other.storageType)) return false;
return true;
}