diff options
author | Jon Bratseth <bratseth@gmail.com> | 2023-03-01 11:58:09 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2023-03-01 11:58:09 +0100 |
commit | aac4ee4d7fa305cdbda4ab82db7f9dc45aa9f090 (patch) | |
tree | 72f1f8437a53ad7330d6d61e05f5e17b3352044e /config-provisioning/src | |
parent | 42f5944056ed2b9d46b1b5538cbcccf0b369ca44 (diff) |
Pass ClusterInfo
Diffstat (limited to 'config-provisioning/src')
3 files changed, 57 insertions, 17 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java index 2477d19d46c..c167c862ce4 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java @@ -20,6 +20,7 @@ public final class Capacity { private final boolean canFail; private final NodeType type; private final Optional<CloudAccount> cloudAccount; + private final ClusterInfo clusterInfo; private Capacity(ClusterResources min, ClusterResources max, @@ -27,7 +28,8 @@ public final class Capacity { boolean required, boolean canFail, NodeType type, - Optional<CloudAccount> cloudAccount) { + Optional<CloudAccount> cloudAccount, + ClusterInfo clusterInfo) { validate(min); validate(max); if (max.smallerThan(min)) @@ -42,6 +44,7 @@ public final class Capacity { this.canFail = canFail; this.type = type; this.cloudAccount = Objects.requireNonNull(cloudAccount); + this.clusterInfo = clusterInfo; } private static void validate(ClusterResources resources) { @@ -77,12 +80,14 @@ public final class Capacity { return cloudAccount; } + public ClusterInfo clusterInfo() { return clusterInfo; } + public Capacity withLimits(ClusterResources min, ClusterResources max) { return withLimits(min, max, IntRange.empty()); } public Capacity withLimits(ClusterResources min, ClusterResources max, IntRange groupSize) { - return new Capacity(min, max, groupSize, required, canFail, type, cloudAccount); + return new Capacity(min, max, groupSize, required, canFail, type, cloudAccount, clusterInfo); } @Override @@ -98,25 +103,21 @@ public final class Capacity { /** Create a non-required, failable capacity request */ public static Capacity from(ClusterResources min, ClusterResources max) { - return from(min, max, IntRange.empty(), false, true, Optional.empty()); + return from(min, max, IntRange.empty(), false, true, Optional.empty(), ClusterInfo.empty()); } public static Capacity from(ClusterResources resources, boolean required, boolean canFail) { return from(resources, required, canFail, NodeType.tenant); } - // TODO: Remove after February 2023 - public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail) { - return new Capacity(min, max, IntRange.empty(), required, canFail, NodeType.tenant, Optional.empty()); - } - - // TODO: Remove after February 2023 - public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) { - return new Capacity(min, max, IntRange.empty(), required, canFail, NodeType.tenant, cloudAccount); + // TODO: Remove after March 2023 + public static Capacity from(ClusterResources min, ClusterResources max, IntRange groupSize, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) { + return new Capacity(min, max, groupSize, required, canFail, NodeType.tenant, cloudAccount, ClusterInfo.empty()); } - public static Capacity from(ClusterResources min, ClusterResources max, IntRange groupSize, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) { - return new Capacity(min, max, groupSize, required, canFail, NodeType.tenant, cloudAccount); + public static Capacity from(ClusterResources min, ClusterResources max, IntRange groupSize, boolean required, boolean canFail, + Optional<CloudAccount> cloudAccount, ClusterInfo clusterInfo) { + return new Capacity(min, max, groupSize, required, canFail, NodeType.tenant, cloudAccount, clusterInfo); } /** Creates this from a node type */ @@ -125,7 +126,7 @@ public final class Capacity { } private static Capacity from(ClusterResources resources, boolean required, boolean canFail, NodeType type) { - return new Capacity(resources, resources, IntRange.empty(), required, canFail, type, Optional.empty()); + return new Capacity(resources, resources, IntRange.empty(), required, canFail, type, Optional.empty(), ClusterInfo.empty()); } } diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterInfo.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterInfo.java index cec5fb1a1ed..dc01c37f854 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterInfo.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterInfo.java @@ -1,2 +1,40 @@ -package com.yahoo.config.provision;public class ClusterInfo { +package com.yahoo.config.provision; + +import java.time.Duration; + +/** + * Auxiliary information about a cluster, provided by the config model to the node repo during a + * capacity request. + * + * @author bratseth + */ +public class ClusterInfo { + + private static final ClusterInfo empty = new ClusterInfo.Builder().build(); + + private final Duration bcpDeadline; + + private ClusterInfo(Builder builder) { + this.bcpDeadline = builder.bcpDeadline; + } + + public Duration bcpDeadline() { return bcpDeadline; } + + public static ClusterInfo empty() { return empty; } + + public static class Builder { + + private Duration bcpDeadline = Duration.ofMinutes(0); + + public Builder bcpDeadline(Duration duration) { + this.bcpDeadline = duration; + return this; + } + + public ClusterInfo build() { + return new ClusterInfo(this); + } + + } + } diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java b/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java index 89c0e98b076..a7614bbc016 100644 --- a/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java +++ b/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java @@ -21,7 +21,8 @@ public class CapacityTest { IntRange.empty(), false, true, - Optional.empty()); + Optional.empty(), + ClusterInfo.empty()); assertValidationFailure(new ClusterResources(4, 2, new NodeResources(1, 2, 3, 4)), new ClusterResources(2, 2, new NodeResources(1, 2, 3, 4))); assertValidationFailure(new ClusterResources(4, 4, new NodeResources(1, 2, 3, 4)), @@ -41,7 +42,7 @@ public class CapacityTest { private void assertValidationFailure(ClusterResources min, ClusterResources max) { try { - Capacity.from(min, max, IntRange.empty(), false, true, Optional.empty()); + Capacity.from(min, max, IntRange.empty(), false, true, Optional.empty(), ClusterInfo.empty()); fail("Expected exception with min " + min + " and max " + max); } catch (IllegalArgumentException e) { |