diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-11-25 16:08:01 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-11-25 16:08:01 +0100 |
commit | 85fa75d145847bce425204f2a520e17f0585f230 (patch) | |
tree | 0e308e392ffe5364d2e7c377f08681961db0f6a6 /controller-api/src/main | |
parent | 667668da4c8808f001a9e09a0dfdc89d1fee1193 (diff) |
Send endpoint weights on deploy
Diffstat (limited to 'controller-api/src/main')
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java index bac34e73dc5..159e4aa15da 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ContainerEndpoint.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.controller.api.integration.configserver; import java.util.List; import java.util.Objects; +import java.util.OptionalInt; /** * This represents a list of one or more names for a container cluster. @@ -14,11 +15,13 @@ public class ContainerEndpoint { private final String clusterId; private final String scope; private final List<String> names; + private final OptionalInt weight; - public ContainerEndpoint(String clusterId, String scope, List<String> names) { - this.clusterId = nonEmpty(clusterId, "message must be non-empty"); + public ContainerEndpoint(String clusterId, String scope, List<String> names, OptionalInt weight) { + this.clusterId = nonEmpty(clusterId, "clusterId must be non-empty"); this.scope = Objects.requireNonNull(scope, "scope must be non-null"); this.names = List.copyOf(Objects.requireNonNull(names, "names must be non-null")); + this.weight = Objects.requireNonNull(weight, "weight must be non-null"); } /** ID of the cluster to which this points */ @@ -39,22 +42,29 @@ public class ContainerEndpoint { return names; } + /** The relative weight of this endpoint */ + public OptionalInt weight() { + return weight; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ContainerEndpoint that = (ContainerEndpoint) o; - return clusterId.equals(that.clusterId) && scope.equals(that.scope) && names.equals(that.names); + return clusterId.equals(that.clusterId) && scope.equals(that.scope) && names.equals(that.names) && weight.equals(that.weight); } @Override public int hashCode() { - return Objects.hash(clusterId, scope, names); + return Objects.hash(clusterId, scope, names, weight); } @Override public String toString() { - return "container endpoint for " + clusterId + ": " + names + " [scope=" + scope + "]"; + return "container endpoint for cluster " + clusterId + ": " + String.join(", ", names) + + " [scope=" + scope + ",weight=" + + weight.stream().boxed().map(Object::toString).findFirst().orElse("<none>") + "]"; } private static String nonEmpty(String s, String message) { |