summaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-11-13 16:39:06 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2019-11-13 16:39:06 +0100
commitf4651191d1a25bc330cbc44ce7896fa54a8e8d00 (patch)
treeb2b3e6c47203d06fa93dacf36d8c96021bf25c91 /config-provisioning
parent8599007b9367bd6c875d739f0b3ae193b83857fe (diff)
Explicit NodeResources defaults
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/abi-spec.json8
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/NodeResources.java17
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java2
3 files changed, 18 insertions, 9 deletions
diff --git a/config-provisioning/abi-spec.json b/config-provisioning/abi-spec.json
index 17e16ceb4b2..61cbc7da52d 100644
--- a/config-provisioning/abi-spec.json
+++ b/config-provisioning/abi-spec.json
@@ -591,7 +591,9 @@
"methods": [
"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 static int compare(com.yahoo.config.provision.NodeResources$DiskSpeed, com.yahoo.config.provision.NodeResources$DiskSpeed)",
+ "public boolean isDefault()",
+ "public static com.yahoo.config.provision.NodeResources$DiskSpeed getDefault()"
],
"fields": [
"public static final enum com.yahoo.config.provision.NodeResources$DiskSpeed fast",
@@ -610,7 +612,9 @@
"methods": [
"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 static int compare(com.yahoo.config.provision.NodeResources$StorageType, com.yahoo.config.provision.NodeResources$StorageType)",
+ "public boolean isDefault()",
+ "public static com.yahoo.config.provision.NodeResources$StorageType getDefault()"
],
"fields": [
"public static final enum com.yahoo.config.provision.NodeResources$StorageType remote",
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 46ad47e9ea0..7769060dc60 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
@@ -36,6 +36,9 @@ public class NodeResources {
throw new IllegalArgumentException(this + " cannot be combined with " + other);
}
+ public boolean isDefault() { return this == getDefault(); }
+ public static DiskSpeed getDefault() { return fast; }
+
}
public enum StorageType {
@@ -64,6 +67,9 @@ public class NodeResources {
throw new IllegalArgumentException(this + " cannot be combined with " + other);
}
+ public boolean isDefault() { return this == getDefault(); }
+ public static StorageType getDefault() { return any; }
+
}
private final double vcpu;
@@ -73,13 +79,12 @@ public class NodeResources {
private final DiskSpeed diskSpeed;
private final StorageType storageType;
- /** Create node resources requiring fast disk */
public NodeResources(double vcpu, double memoryGb, double diskGb, double bandwidthGbps) {
- this(vcpu, memoryGb, diskGb, bandwidthGbps, DiskSpeed.fast);
+ this(vcpu, memoryGb, diskGb, bandwidthGbps, DiskSpeed.getDefault());
}
public NodeResources(double vcpu, double memoryGb, double diskGb, double bandwidthGbps, DiskSpeed diskSpeed) {
- this(vcpu, memoryGb, diskGb, bandwidthGbps, diskSpeed, StorageType.any);
+ this(vcpu, memoryGb, diskGb, bandwidthGbps, diskSpeed, StorageType.getDefault());
}
public NodeResources(double vcpu, double memoryGb, double diskGb, double bandwidthGbps, DiskSpeed diskSpeed, StorageType storageType) {
@@ -185,8 +190,8 @@ public class NodeResources {
public String toString() {
return "[vcpu: " + vcpu + ", memory: " + memoryGb + " Gb, disk " + diskGb + " Gb" +
(bandwidthGbps > 0 ? ", bandwidth: " + bandwidthGbps + " Gbps" : "") +
- (diskSpeed != DiskSpeed.fast ? ", disk speed: " + diskSpeed : "") +
- (storageType != StorageType.any ? ", storage type: " + storageType : "") + "]";
+ ( ! diskSpeed.isDefault() ? ", disk speed: " + diskSpeed : "") +
+ ( ! storageType.isDefault() ? ", storage type: " + storageType : "") + "]";
}
/** Returns true if all the resources of this are the same or larger than the given resources */
@@ -237,7 +242,7 @@ public class NodeResources {
if (cpu == 0) cpu = 0.5;
if (cpu == 2 && mem == 8 ) cpu = 1.5;
if (cpu == 2 && mem == 12 ) cpu = 2.3;
- return new NodeResources(cpu, mem, dsk, 0.3, DiskSpeed.fast, StorageType.any);
+ return new NodeResources(cpu, mem, dsk, 0.3, DiskSpeed.getDefault(), StorageType.getDefault());
}
}
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java
index c7630f06552..413e277655a 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/serialization/AllocatedHostsSerializer.java
@@ -177,7 +177,7 @@ public class AllocatedHostsSerializer {
}
private static NodeResources.StorageType storageTypeFromSlime(Inspector storageType) {
- if ( ! storageType.valid()) return NodeResources.StorageType.any; // TODO: Remove this line after December 2019
+ if ( ! storageType.valid()) return NodeResources.StorageType.getDefault(); // TODO: Remove this line after December 2019
switch (storageType.asString()) {
case "remote" : return NodeResources.StorageType.remote;
case "local" : return NodeResources.StorageType.local;