diff options
author | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-09-04 14:26:42 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@verizonmedia.com> | 2019-09-05 14:01:04 +0200 |
commit | a6df4a3d2bec2eaf22460390e540cf06abdc8a1a (patch) | |
tree | d73707e5ddde6bcef0ee19af9cf85917b876ac57 /flags | |
parent | 6749cf5a7f82fe2330689bb42c3ab12ed730238e (diff) |
Define provision-capacity flag
Diffstat (limited to 'flags')
-rw-r--r-- | flags/src/main/java/com/yahoo/vespa/flags/Flags.java | 7 | ||||
-rw-r--r-- | flags/src/main/java/com/yahoo/vespa/flags/custom/PreprovisionCapacity.java | 73 |
2 files changed, 80 insertions, 0 deletions
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java index 527d53dc830..fefed6cc05e 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.flags; import com.yahoo.vespa.defaults.Defaults; +import com.yahoo.vespa.flags.custom.PreprovisionCapacity; import java.util.List; import java.util.Optional; @@ -111,6 +112,12 @@ public class Flags { "Takes effect on next deployment", APPLICATION_ID); + public static final UnboundListFlag<PreprovisionCapacity> PREPROVISION_CAPACITY = defineListFlag( + "preprovision-capacity", List.of(), PreprovisionCapacity.class, + "List of node resources and their count that should be present in zone to receive new deployments. When a " + + "preprovisioned is taken, new will be provisioned within next iteration of maintainer.", + "Takes effect on next iteration of HostProivisionMaintainer."); + public static final UnboundListFlag<String> DISABLED_DYNAMIC_PROVISIONING_FLAVORS = defineListFlag( "disabled-dynamic-provisioning-flavors", List.of(), String.class, "List of disabled Vespa flavor names that cannot be used for dynamic provisioning", diff --git a/flags/src/main/java/com/yahoo/vespa/flags/custom/PreprovisionCapacity.java b/flags/src/main/java/com/yahoo/vespa/flags/custom/PreprovisionCapacity.java new file mode 100644 index 00000000000..83a6eeed984 --- /dev/null +++ b/flags/src/main/java/com/yahoo/vespa/flags/custom/PreprovisionCapacity.java @@ -0,0 +1,73 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.flags.custom; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; + +/** + * @author freva + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class PreprovisionCapacity { + @JsonProperty("vcpu") + private final double vcpu; + + @JsonProperty("memoryGb") + private final double memoryGb; + + @JsonProperty("diskGb") + private final double diskGb; + + @JsonProperty("count") + private final int count; + + public PreprovisionCapacity(@JsonProperty("vcpu") double vcpu, + @JsonProperty("memoryGb") double memoryGb, + @JsonProperty("diskGb") double diskGb, + @JsonProperty("count") int count) { + this.vcpu = requirePositive("vcpu", vcpu); + this.memoryGb = requirePositive("memoryGb", memoryGb); + this.diskGb = requirePositive("diskGb", diskGb); + this.count = (int) requirePositive("count", count); + } + + public double getVcpu() { + return vcpu; + } + + public double getMemoryGb() { + return memoryGb; + } + + public double getDiskGb() { + return diskGb; + } + + public int getCount() { + return count; + } + + private static double requirePositive(String name, double value) { + if (value < 1) + throw new IllegalArgumentException("'" + name + "' must be positive, was " + value); + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PreprovisionCapacity that = (PreprovisionCapacity) o; + return Double.compare(that.vcpu, vcpu) == 0 && + Double.compare(that.memoryGb, memoryGb) == 0 && + Double.compare(that.diskGb, diskGb) == 0 && + count == that.count; + } + + @Override + public int hashCode() { + return Objects.hash(vcpu, memoryGb, diskGb, count); + } +}
\ No newline at end of file |