diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2019-11-14 21:13:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-14 21:13:07 +0100 |
commit | 52a5a424000cb4a1bcc61e601c6f4a183103e3d1 (patch) | |
tree | 4626bdbc78cfc821d54db2e96dbbb09aa25cff08 /config-provisioning | |
parent | b4d2e83cf7c823b823ef1cabc934f616ea499792 (diff) | |
parent | 61050a1678c5e2da424f6e8d21d5fa4b63fe114f (diff) |
Merge pull request #11306 from vespa-engine/bratseth/compatible-checkable-resource-enums
Move compatible check to enums
Diffstat (limited to 'config-provisioning')
-rw-r--r-- | config-provisioning/abi-spec.json | 2 | ||||
-rw-r--r-- | config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java | 12 |
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; } |