summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2019-10-16 21:00:08 +0200
committerGitHub <noreply@github.com>2019-10-16 21:00:08 +0200
commitec278bedb5a787309d11d356018ad5e2afc0862a (patch)
treefca0df7708275c2948edd8cdc2de0418a5bd798b /config-provisioning
parent0f378f6aeae4ab1afef700ee49257ff2074e4d14 (diff)
parent572ae7743f49863541d56e79bbec42da706cb314 (diff)
Merge pull request #10998 from vespa-engine/bratseth/balanced-allocation
Pick hosts for nodes to reduce resource allocation skew
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/abi-spec.json3
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java17
2 files changed, 18 insertions, 2 deletions
diff --git a/config-provisioning/abi-spec.json b/config-provisioning/abi-spec.json
index dc9dc80fddf..32fb870150e 100644
--- a/config-provisioning/abi-spec.json
+++ b/config-provisioning/abi-spec.json
@@ -587,7 +587,8 @@
],
"methods": [
"public static com.yahoo.config.provision.NodeResources$DiskSpeed[] values()",
- "public static com.yahoo.config.provision.NodeResources$DiskSpeed valueOf(java.lang.String)"
+ "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)"
],
"fields": [
"public static final enum com.yahoo.config.provision.NodeResources$DiskSpeed fast",
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 4469eef98cf..5687697aff9 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
@@ -11,9 +11,24 @@ import java.util.Objects;
public class NodeResources {
public enum DiskSpeed {
+
fast, // SSD disk or similar speed is needed
slow, // This is tuned to work with the speed of spinning disks
- any // The performance of the cluster using this does not depend on disk speed
+ any; // The performance of the cluster using this does not depend on disk speed
+
+ /**
+ * Compares disk speeds by cost: Slower is cheaper, and therefore before.
+ * Any can be slow and therefore costs the same as slow.
+ */
+ public static int compare(DiskSpeed a, DiskSpeed b) {
+ if (a == any) a = slow;
+ if (b == any) b = slow;
+
+ if (a == slow && b == fast) return -1;
+ if (a == fast && b == slow) return 1;
+ return 0;
+ }
+
}
private final double vcpu;