From cd42e7baa4bdeed028c1690c2371b0f05655fbe0 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Mon, 9 Jan 2023 09:58:11 +0100 Subject: minCount in SharedHost is not used anymore, simplify --- .../com/yahoo/vespa/flags/custom/SharedHost.java | 30 ++-------------------- .../com/yahoo/vespa/flags/PermanentFlagsTest.java | 3 +-- .../yahoo/vespa/flags/custom/SharedHostTest.java | 4 +-- 3 files changed, 5 insertions(+), 32 deletions(-) (limited to 'flags/src') diff --git a/flags/src/main/java/com/yahoo/vespa/flags/custom/SharedHost.java b/flags/src/main/java/com/yahoo/vespa/flags/custom/SharedHost.java index 2311c7cbf40..0d05eb1ae96 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/custom/SharedHost.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/custom/SharedHost.java @@ -20,25 +20,20 @@ import java.util.Objects; @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(value = JsonInclude.Include.NON_NULL) public class SharedHost { - private final int DEFAULT_MIN_COUNT = 0; private final List resources; - private final int minCount; public static SharedHost createDisabled() { - return new SharedHost(null, null); + return new SharedHost(null); } /** * @param resourcesOrNull the resources of the shared host (or several to support e.g. tiers or * fast/slow disks separately) - * @param minCountOrNull the minimum number of shared hosts */ @JsonCreator - public SharedHost(@JsonProperty("resources") List resourcesOrNull, - @JsonProperty("min-count") Integer minCountOrNull) { + public SharedHost(@JsonProperty("resources") List resourcesOrNull) { this.resources = resourcesOrNull == null ? List.of() : List.copyOf(resourcesOrNull); - this.minCount = requireNonNegative(minCountOrNull, DEFAULT_MIN_COUNT, "min-count"); } @JsonGetter("resources") @@ -46,11 +41,6 @@ public class SharedHost { return resources.isEmpty() ? null : resources; } - @JsonGetter("min-count") - public Integer getMinCountOrNull() { - return minCount == DEFAULT_MIN_COUNT ? null : minCount; - } - @JsonIgnore public boolean isEnabled(String clusterType) { return resources.stream().anyMatch(hr -> hr.satisfiesClusterType(clusterType)); @@ -61,11 +51,6 @@ public class SharedHost { return resources; } - @JsonIgnore - public int getMinCount() { - return minCount; - } - @Override public String toString() { return resources.toString(); @@ -84,15 +69,4 @@ public class SharedHost { return Objects.hash(resources); } - private int requireNonNegative(Integer integerOrNull, int defaultValue, String fieldName) { - if (integerOrNull == null) { - return defaultValue; - } - - if (integerOrNull < 0) { - throw new IllegalArgumentException(fieldName + " cannot be negative"); - } - - return integerOrNull; - } } diff --git a/flags/src/test/java/com/yahoo/vespa/flags/PermanentFlagsTest.java b/flags/src/test/java/com/yahoo/vespa/flags/PermanentFlagsTest.java index 8cac286be5e..903b0d899e2 100644 --- a/flags/src/test/java/com/yahoo/vespa/flags/PermanentFlagsTest.java +++ b/flags/src/test/java/com/yahoo/vespa/flags/PermanentFlagsTest.java @@ -17,8 +17,7 @@ class PermanentFlagsTest { public void testSharedHostFlag() { SharedHost sharedHost = new SharedHost(List.of(new HostResources(4.0, 16.0, 50.0, 0.3, "fast", "local", "admin", - 10, "x86_64")), - null); + 10, "x86_64"))); testGeneric(PermanentFlags.SHARED_HOST, sharedHost); } diff --git a/flags/src/test/java/com/yahoo/vespa/flags/custom/SharedHostTest.java b/flags/src/test/java/com/yahoo/vespa/flags/custom/SharedHostTest.java index 1c8fbc41d35..4726726e70e 100644 --- a/flags/src/test/java/com/yahoo/vespa/flags/custom/SharedHostTest.java +++ b/flags/src/test/java/com/yahoo/vespa/flags/custom/SharedHostTest.java @@ -14,10 +14,10 @@ public class SharedHostTest { void serialization() throws IOException { verifySerialization(new SharedHost(List.of( new HostResources(1.0, 2.0, 3.0, 4.0, "fast", "remote", - "container", 5, "x86_64")), 6)); + "container", 5, "x86_64")))); verifySerialization(new SharedHost(List.of( new HostResources(1.0, 2.0, 3.0, 4.0, "fast", "remote", - "admin", 5, "arm64")), null)); + "admin", 5, "arm64")))); } private void verifySerialization(SharedHost sharedHost) throws IOException { -- cgit v1.2.3