diff options
author | Martin Polden <mpolden@mpolden.no> | 2020-06-29 10:19:49 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2020-06-29 14:41:52 +0200 |
commit | 17a43c36fa8dfb03f1a87293e02475818fbe04d7 (patch) | |
tree | 849e6727a679afad4708ff523e6eab738007b424 /controller-server | |
parent | 97dfae5b40f9f9a1aeb72caac363f82a27c1f381 (diff) |
Include weighted endpoint in endpoint list
Diffstat (limited to 'controller-server')
3 files changed, 18 insertions, 13 deletions
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 98169ba3196..3b1926fa6e9 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 @@ -82,7 +82,7 @@ public class RoutingController { return rotationRepository; } - /** Returns zone-scoped endpoints for given deployment */ + /** Returns endpoints for given deployment */ public EndpointList endpointsOf(DeploymentId deployment) { var endpoints = new LinkedHashSet<Endpoint>(); boolean isSystemApplication = SystemApplication.matching(deployment.applicationId()).isPresent(); @@ -93,6 +93,7 @@ public class RoutingController { for (var routingMethod : controller.zoneRegistry().routingMethods(policy.id().zone())) { if (routingMethod.isDirect() && !isSystemApplication && !canRouteDirectlyTo(deployment, application.get())) continue; endpoints.add(policy.endpointIn(controller.system(), routingMethod, controller.zoneRegistry())); + endpoints.add(policy.weightedEndpointIn(controller.system(), routingMethod)); } } return EndpointList.copyOf(endpoints); @@ -134,7 +135,7 @@ public class RoutingController { return EndpointList.copyOf(endpoints); } - /** Returns all non-global endpoints and corresponding cluster IDs for given deployments, grouped by their zone */ + /** Returns all zone-scoped endpoints and corresponding cluster IDs for given deployments, grouped by their zone */ public Map<ZoneId, List<Endpoint>> zoneEndpointsOf(Collection<DeploymentId> deployments) { var endpoints = new TreeMap<ZoneId, List<Endpoint>>(Comparator.comparing(ZoneId::value)); for (var deployment : deployments) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index 54004685cf1..dc3c14c76b7 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -44,11 +44,11 @@ import com.yahoo.vespa.hosted.controller.api.application.v4.model.configserverbi import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname; import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId; +import com.yahoo.vespa.hosted.controller.api.integration.configserver.Application; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Cluster; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.Application; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationVersion; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobId; import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType; @@ -95,7 +95,6 @@ import javax.ws.rs.NotAuthorizedException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.math.RoundingMode; import java.net.URI; import java.net.URISyntaxException; import java.security.DigestInputStream; @@ -104,8 +103,6 @@ import java.security.PublicKey; import java.time.DayOfWeek; import java.time.Duration; import java.time.Instant; -import java.time.YearMonth; -import java.time.format.DateTimeParseException; import java.util.Arrays; import java.util.Base64; import java.util.Comparator; @@ -116,7 +113,6 @@ import java.util.Map; import java.util.Optional; import java.util.OptionalLong; import java.util.Scanner; -import java.util.Set; import java.util.StringJoiner; import java.util.logging.Level; import java.util.stream.Collectors; @@ -975,7 +971,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { // Add zone endpoints var endpointArray = response.setArray("endpoints"); - for (var endpoint : controller.routing().endpointsOf(deploymentId)) { + for (var endpoint : controller.routing().endpointsOf(deploymentId).scope(Endpoint.Scope.zone)) { toSlime(endpoint, endpoint.name(), endpointArray.addObject()); } // Add global endpoints diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java index c56a5f0bd66..7f4a707949b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/routing/RoutingPolicy.java @@ -74,11 +74,12 @@ public class RoutingPolicy { Optional<Endpoint> infraEndpoint = SystemApplication.matching(id.owner()) .flatMap(app -> app.endpointIn(id.zone(), zoneRegistry)); if (infraEndpoint.isPresent()) return infraEndpoint.get(); - return Endpoint.of(id.owner()) - .target(id.cluster(), id.zone()) - .on(Port.fromRoutingMethod(routingMethod)) - .routingMethod(routingMethod) - .in(system); + return endpoint(routingMethod).in(system); + } + + /** Returns the weighted endpoint of this */ + public Endpoint weightedEndpointIn(SystemName system, RoutingMethod routingMethod) { + return endpoint(routingMethod).weighted().in(system); } @Override @@ -101,4 +102,11 @@ public class RoutingPolicy { id.zone().value()); } + private Endpoint.EndpointBuilder endpoint(RoutingMethod routingMethod) { + return Endpoint.of(id.owner()) + .target(id.cluster(), id.zone()) + .on(Port.fromRoutingMethod(routingMethod)) + .routingMethod(routingMethod); + } + } |