diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-11-08 15:06:05 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-11-09 14:20:27 +0100 |
commit | 08a1bc42a544f5d6193850f95137b9f21d41c16a (patch) | |
tree | eb2f76658641f5f20c603e637e045767da14bc48 | |
parent | f610c39bdec3aae45b323682b3c62687ccaa0a79 (diff) |
Add scope to container endpoint
2 files changed, 22 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 3e9169a83aa..bac34e73dc5 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 @@ -12,10 +12,12 @@ import java.util.Objects; public class ContainerEndpoint { private final String clusterId; + private final String scope; private final List<String> names; - public ContainerEndpoint(String clusterId, List<String> names) { + public ContainerEndpoint(String clusterId, String scope, List<String> names) { this.clusterId = nonEmpty(clusterId, "message 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")); } @@ -24,6 +26,11 @@ public class ContainerEndpoint { return clusterId; } + /** The scope of this endpoint */ + public String scope() { + return scope; + } + /** * All valid DNS names for this endpoint. This can contain both proper DNS names and synthetic identifiers used for * routing, such as a Host header value that is not necessarily a proper DNS name. @@ -37,18 +44,17 @@ public class ContainerEndpoint { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ContainerEndpoint that = (ContainerEndpoint) o; - return clusterId.equals(that.clusterId) && - names.equals(that.names); + return clusterId.equals(that.clusterId) && scope.equals(that.scope) && names.equals(that.names); } @Override public int hashCode() { - return Objects.hash(clusterId, names); + return Objects.hash(clusterId, scope, names); } @Override public String toString() { - return "container endpoint for " + clusterId + " " + names; + return "container endpoint for " + clusterId + ": " + names + " [scope=" + scope + "]"; } private static String nonEmpty(String s, String message) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java index 6afee557029..ffaa0f2cb53 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/RoutingController.java @@ -277,6 +277,7 @@ public class RoutingController { // Include rotation ID as a valid name of this container endpoint (required by global routing health checks) names.add(assignedRotation.rotationId().asString()); containerEndpoints.add(new ContainerEndpoint(assignedRotation.clusterId().value(), + asString(Endpoint.Scope.global), names)); } // Add endpoints not backed by a rotation (i.e. other routing methods so that the config server always knows @@ -287,6 +288,7 @@ public class RoutingController { .groupingBy(Endpoint::cluster) .forEach((clusterId, clusterEndpoints) -> { containerEndpoints.add(new ContainerEndpoint(clusterId.value(), + asString(Endpoint.Scope.global), clusterEndpoints.mapToList(Endpoint::dnsName))); }); return Collections.unmodifiableSet(containerEndpoints); @@ -411,5 +413,14 @@ public class RoutingController { return endpoints; } + private static String asString(Endpoint.Scope scope) { + switch (scope) { + case application: return "application"; + case global: return "global"; + case weighted: return "weighted"; + case zone: return "zone"; + } + throw new IllegalArgumentException("Unknown scope " + scope); + } } |