diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-01-24 10:41:43 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-02-02 16:01:08 +0100 |
commit | 65b3ce3ce516a56d2df99bafdbf1d453ba5c9557 (patch) | |
tree | c2163de2e9dce7830686ced1f2ee175db73109e9 /controller-server | |
parent | f0986e5521d6a8b678bdfe618ca77d4b21df282b (diff) |
Clean
Diffstat (limited to 'controller-server')
3 files changed, 10 insertions, 43 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index 4d8591ce800..85729851124 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller; +import com.google.common.collect.ImmutableList; import com.yahoo.component.Version; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.application.api.ValidationId; @@ -10,7 +11,6 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.athenz.api.NToken; import com.yahoo.vespa.curator.Lock; import com.yahoo.vespa.hosted.controller.api.ActivateResult; -import com.yahoo.vespa.hosted.controller.api.InstanceEndpoints; import com.yahoo.vespa.hosted.controller.api.Tenant; import com.yahoo.vespa.hosted.controller.api.application.v4.model.DeployOptions; import com.yahoo.vespa.hosted.controller.api.application.v4.model.EndpointStatus; @@ -509,24 +509,18 @@ public class ApplicationController { } } - /** Returns the endpoints of the deployment, or empty if obtaining them failed */ - public Optional<InstanceEndpoints> getDeploymentEndpoints(DeploymentId deploymentId) { + /** Returns the endpoints of the deployment, or an empty list if the request fails */ + public List<URI> getDeploymentEndpoints(DeploymentId deploymentId) { try { - List<RoutingEndpoint> endpoints = routingGenerator.endpoints(deploymentId); - List<URI> endPointUrls = new ArrayList<>(); - for (RoutingEndpoint endpoint : endpoints) { - try { - endPointUrls.add(new URI(endpoint.getEndpoint())); - } catch (URISyntaxException e) { - throw new RuntimeException("Routing generator returned illegal url's", e); - } - } - return Optional.of(new InstanceEndpoints(endPointUrls)); + return ImmutableList.copyOf(routingGenerator.endpoints(deploymentId).stream() + .map(RoutingEndpoint::getEndpoint) + .map(URI::create) + ::iterator); } catch (RuntimeException e) { log.log(Level.WARNING, "Failed to get endpoint information for " + deploymentId + ": " + Exceptions.toMessageString(e)); - return Optional.empty(); + return Collections.emptyList(); } } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/InstanceEndpoints.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/InstanceEndpoints.java deleted file mode 100644 index b9ed439eb8b..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/api/InstanceEndpoints.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.api; - -import java.net.URI; -import java.util.List; - -/** - * @author Tony Vaagenes - */ -public class InstanceEndpoints { - - private final List<URI> containerEndpoints; - - public InstanceEndpoints(List<URI> containerEndpoints) { - this.containerEndpoints = containerEndpoints; - } - - public List<URI> getContainerEndpoints() { - return containerEndpoints; - } -} - - 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 9b2174b881d..ab87165dfcc 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 @@ -25,7 +25,6 @@ import com.yahoo.vespa.hosted.controller.Application; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.NotExistsException; import com.yahoo.vespa.hosted.controller.api.ActivateResult; -import com.yahoo.vespa.hosted.controller.api.InstanceEndpoints; import com.yahoo.vespa.hosted.controller.api.Tenant; import com.yahoo.vespa.hosted.controller.api.application.v4.ApplicationResource; import com.yahoo.vespa.hosted.controller.api.application.v4.EnvironmentResource; @@ -439,12 +438,9 @@ public class ApplicationApiHandler extends LoggingRequestHandler { private void toSlime(Cursor response, DeploymentId deploymentId, Deployment deployment, HttpRequest request) { - Optional<InstanceEndpoints> deploymentEndpoints = controller.applications().getDeploymentEndpoints(deploymentId); Cursor serviceUrlArray = response.setArray("serviceUrls"); - if (deploymentEndpoints.isPresent()) { - for (URI uri : deploymentEndpoints.get().getContainerEndpoints()) - serviceUrlArray.addString(uri.toString()); - } + controller.applications().getDeploymentEndpoints(deploymentId) + .forEach(uri -> serviceUrlArray.addString(uri.toString())); response.setString("nodes", withPath("/zone/v2/" + deploymentId.zoneId().environment() + "/" + deploymentId.zoneId().region() + "/nodes/v2/node/?&recursive=true&application=" + deploymentId.applicationId().tenant() + "." + deploymentId.applicationId().application() + "." + deploymentId.applicationId().instance(), request.getUri()).toString()); |