aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning/src
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/src
parent150599b247afe2a47d917dcf973849cc3451b9ac (diff)
Move compatible check to enums
Diffstat (limited to 'config-provisioning/src')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java12
1 files changed, 10 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 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;
}