From 7df30aeb447d37347fc138151dd0c0fa11e07cf8 Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Thu, 18 Feb 2021 16:02:07 +0100 Subject: Simplify by extending SlimeJsonResponse --- .../hosted/provision/restapi/NodesResponse.java | 23 +++------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'node-repository') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java index 1175736e517..19895c845e5 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java @@ -8,10 +8,8 @@ import com.yahoo.config.provision.Flavor; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.serialization.NetworkPortsSerializer; import com.yahoo.container.jdisc.HttpRequest; -import com.yahoo.container.jdisc.HttpResponse; +import com.yahoo.restapi.SlimeJsonResponse; import com.yahoo.slime.Cursor; -import com.yahoo.slime.JsonFormat; -import com.yahoo.slime.Slime; import com.yahoo.vespa.applicationmodel.HostName; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; @@ -22,8 +20,6 @@ import com.yahoo.vespa.orchestrator.Orchestrator; import com.yahoo.vespa.orchestrator.status.HostInfo; import com.yahoo.vespa.orchestrator.status.HostStatus; -import java.io.IOException; -import java.io.OutputStream; import java.net.URI; import java.util.List; import java.util.Optional; @@ -33,7 +29,7 @@ import java.util.function.Function; /** * @author bratseth */ -class NodesResponse extends HttpResponse { +class NodesResponse extends SlimeJsonResponse { /** The responses this can create */ public enum ResponseType { nodeList, stateList, nodesInStateList, singleNode } @@ -48,19 +44,16 @@ class NodesResponse extends HttpResponse { private final boolean recursive; private final Function> orchestrator; private final NodeRepository nodeRepository; - private final Slime slime; public NodesResponse(ResponseType responseType, HttpRequest request, Orchestrator orchestrator, NodeRepository nodeRepository) { - super(200); this.parentUrl = toParentUrl(request); this.nodeParentUrl = toNodeParentUrl(request); - filter = NodesV2ApiHandler.toNodeFilter(request); + this.filter = NodesV2ApiHandler.toNodeFilter(request); this.recursive = request.getBooleanProperty("recursive"); this.orchestrator = orchestrator.getHostResolver(); this.nodeRepository = nodeRepository; - slime = new Slime(); Cursor root = slime.setObject(); switch (responseType) { case nodeList: nodesToSlime(root); break; @@ -84,16 +77,6 @@ class NodesResponse extends HttpResponse { return uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() + "/nodes/v2/node/"; } - @Override - public void render(OutputStream stream) throws IOException { - new JsonFormat(true).encode(stream, slime); - } - - @Override - public String getContentType() { - return "application/json"; - } - private void statesToSlime(Cursor root) { Cursor states = root.setObject("states"); for (Node.State state : Node.State.values()) -- cgit v1.2.3 From 5ef09c7e37133b9352448de3ededb26b01785a35 Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Thu, 18 Feb 2021 16:02:49 +0100 Subject: Expose FlagSource in NodeRepository --- .../com/yahoo/vespa/hosted/provision/NodeRepository.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'node-repository') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java index 55495669802..059874f6ae7 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java @@ -60,6 +60,7 @@ public class NodeRepository extends AbstractComponent { private final JobControl jobControl; private final Applications applications; private final LoadBalancers loadBalancers; + private final FlagSource flagSource; private final int spareCount; /** @@ -122,6 +123,7 @@ public class NodeRepository extends AbstractComponent { this.jobControl = new JobControl(new JobControlFlags(db, flagSource)); this.applications = new Applications(db); this.loadBalancers = new LoadBalancers(db); + this.flagSource = flagSource; this.spareCount = spareCount; rewriteNodes(); } @@ -174,6 +176,14 @@ public class NodeRepository extends AbstractComponent { public HostResourcesCalculator resourcesCalculator() { return resourcesCalculator; } + public FlagSource flagSource() { return flagSource; } + + /** Returns the time keeper of this system */ + public Clock clock() { return clock; } + + /** Returns the zone of this system */ + public Zone zone() { return zone; } + /** The number of nodes we should ensure has free capacity for node failures whenever possible */ public int spareCount() { return spareCount; } @@ -204,10 +214,4 @@ public class NodeRepository extends AbstractComponent { applications.remove(transaction); } - /** Returns the time keeper of this system */ - public Clock clock() { return clock; } - - /** Returns the zone of this system */ - public Zone zone() { return zone; } - } -- cgit v1.2.3 From 7c5b955926932bf2197ce2782a259a457387bfa1 Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Thu, 18 Feb 2021 16:06:22 +0100 Subject: Fix TODO --- .../java/com/yahoo/vespa/hosted/provision/NodeRepository.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'node-repository') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java index 059874f6ae7..e0c890aed8c 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/NodeRepository.java @@ -103,11 +103,10 @@ public class NodeRepository extends AbstractComponent { boolean useCuratorClientCache, int spareCount, long nodeCacheSize) { - // TODO (valerijf): Uncomment when exception for prod.cd-aws is removed -// if (provisionServiceProvider.getHostProvisioner().isPresent() != zone.getCloud().dynamicProvisioning()) -// throw new IllegalArgumentException(String.format( -// "dynamicProvisioning property must be 1-to-1 with availability of HostProvisioner, was: dynamicProvisioning=%s, hostProvisioner=%s", -// zone.getCloud().dynamicProvisioning(), provisionServiceProvider.getHostProvisioner().map(__ -> "present").orElse("empty"))); + if (provisionServiceProvider.getHostProvisioner().isPresent() != zone.getCloud().dynamicProvisioning()) + throw new IllegalArgumentException(String.format( + "dynamicProvisioning property must be 1-to-1 with availability of HostProvisioner, was: dynamicProvisioning=%s, hostProvisioner=%s", + zone.getCloud().dynamicProvisioning(), provisionServiceProvider.getHostProvisioner().map(__ -> "present").orElse("empty"))); this.db = new CuratorDatabaseClient(flavors, curator, clock, zone, useCuratorClientCache, nodeCacheSize); this.zone = zone; -- cgit v1.2.3 From 6a3b7efa2de5a0639648fbd0a54287f187d4b74f Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Thu, 18 Feb 2021 16:26:10 +0100 Subject: Expose nodeArchiveUrl in nodes response --- .../hosted/provision/restapi/NodesResponse.java | 31 +++++++++++- .../provision/restapi/NodesResponseTest.java | 56 ++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java (limited to 'node-repository') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java index 19895c845e5..086a476e4b6 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java @@ -11,6 +11,9 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.restapi.SlimeJsonResponse; import com.yahoo.slime.Cursor; import com.yahoo.vespa.applicationmodel.HostName; +import com.yahoo.vespa.flags.FetchVector; +import com.yahoo.vespa.flags.FlagSource; +import com.yahoo.vespa.flags.Flags; import com.yahoo.vespa.hosted.provision.Node; import com.yahoo.vespa.hosted.provision.NodeRepository; import com.yahoo.vespa.hosted.provision.node.Address; @@ -45,7 +48,7 @@ class NodesResponse extends SlimeJsonResponse { private final Function> orchestrator; private final NodeRepository nodeRepository; - public NodesResponse(ResponseType responseType, HttpRequest request, + public NodesResponse(ResponseType responseType, HttpRequest request, Orchestrator orchestrator, NodeRepository nodeRepository) { this.parentUrl = toParentUrl(request); this.nodeParentUrl = toNodeParentUrl(request); @@ -175,6 +178,7 @@ class NodesResponse extends SlimeJsonResponse { node.reports().toSlime(object, "reports"); node.modelName().ifPresent(modelName -> object.setString("modelName", modelName)); node.switchHostname().ifPresent(switchHostname -> object.setString("switchHostname", switchHostname)); + nodeArchiveUrl(nodeRepository.flagSource(), node).ifPresent(url -> object.setString("nodeArchiveUrl", url)); } private void toSlime(ApplicationId id, Cursor object) { @@ -229,4 +233,29 @@ class NodesResponse extends SlimeJsonResponse { return path.substring(lastSlash+1); } + static Optional nodeArchiveUrl(FlagSource flagSource, Node node) { + String bucket = Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.bindTo(flagSource) + .with(FetchVector.Dimension.NODE_TYPE, node.type().name()) + .with(FetchVector.Dimension.APPLICATION_ID, node.allocation().map(alloc -> alloc.owner().serializedForm()).orElse(null)) + .value(); + if (bucket.isBlank()) return Optional.empty(); + + StringBuilder sb = new StringBuilder(100).append("s3://").append(bucket).append('/'); + if (node.type() == NodeType.tenant) { + if (node.allocation().isEmpty()) return Optional.empty(); + ApplicationId app = node.allocation().get().owner(); + + sb.append(app.tenant().value()).append('/').append(app.application().value()).append('/').append(app.instance().value()).append('/'); + } else { + sb.append("hosted-vespa/"); + } + + for (char c: node.hostname().toCharArray()) { + if (c == '.') break; + sb.append(c); + } + + return Optional.of(sb.append('/').toString()); + } + } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java new file mode 100644 index 00000000000..508f8cd4c48 --- /dev/null +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java @@ -0,0 +1,56 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.provision.restapi; + +import com.yahoo.component.Version; +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ClusterMembership; +import com.yahoo.config.provision.Flavor; +import com.yahoo.config.provision.NodeResources; +import com.yahoo.config.provision.NodeType; +import com.yahoo.vespa.flags.Flags; +import com.yahoo.vespa.flags.InMemoryFlagSource; +import com.yahoo.vespa.hosted.provision.Node; +import com.yahoo.vespa.hosted.provision.node.Allocation; +import com.yahoo.vespa.hosted.provision.node.Generation; +import org.junit.Test; + +import java.util.Optional; + +import static org.junit.Assert.assertEquals; + +/** + * @author freva + */ +public class NodesResponseTest { + private final InMemoryFlagSource flagSource = new InMemoryFlagSource(); + + @Test + public void node_archive_url() { + ApplicationId app = ApplicationId.from("vespa", "music", "main"); + // Flag not set, no archive url + assertNodeArchiveUrl(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); + assertNodeArchiveUrl(null, "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); + + flagSource.withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "vespa-data-bucket"); + // Flag is set, but node not allocated, only sync non-tenant nodes + assertNodeArchiveUrl(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, null); + assertNodeArchiveUrl("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, null); + + // Flag is set and node is allocated + assertNodeArchiveUrl("s3://vespa-data-bucket/vespa/music/main/h432a/", "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); + assertNodeArchiveUrl("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); + } + + private void assertNodeArchiveUrl(String archiveUrl, String hostname, NodeType type, ApplicationId appId) { + Node.Builder nodeBuilder = Node.create("id", hostname, new Flavor(NodeResources.unspecified()), Node.State.parked, type); + Optional.ofNullable(appId) + .map(app -> new Allocation(app, + ClusterMembership.from("container/default/0/0", Version.fromString("1.2.3"), Optional.empty()), + NodeResources.unspecified(), + Generation.initial(), + false)) + .ifPresent(nodeBuilder::allocation); + + assertEquals(archiveUrl, NodesResponse.nodeArchiveUrl(flagSource, nodeBuilder.build()).orElse(null)); + } +} \ No newline at end of file -- cgit v1.2.3 From de9b879133e4fb446decf200d9e6467666c9ea65 Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Fri, 19 Feb 2021 08:36:33 +0100 Subject: nodeArchiveUrl -> nodeArchiveUri --- .../vespa/hosted/provision/restapi/NodesResponse.java | 4 ++-- .../hosted/provision/restapi/NodesResponseTest.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'node-repository') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java index 086a476e4b6..52625fe113a 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java @@ -178,7 +178,7 @@ class NodesResponse extends SlimeJsonResponse { node.reports().toSlime(object, "reports"); node.modelName().ifPresent(modelName -> object.setString("modelName", modelName)); node.switchHostname().ifPresent(switchHostname -> object.setString("switchHostname", switchHostname)); - nodeArchiveUrl(nodeRepository.flagSource(), node).ifPresent(url -> object.setString("nodeArchiveUrl", url)); + nodeArchiveUri(nodeRepository.flagSource(), node).ifPresent(url -> object.setString("nodeArchiveUri", url)); } private void toSlime(ApplicationId id, Cursor object) { @@ -233,7 +233,7 @@ class NodesResponse extends SlimeJsonResponse { return path.substring(lastSlash+1); } - static Optional nodeArchiveUrl(FlagSource flagSource, Node node) { + static Optional nodeArchiveUri(FlagSource flagSource, Node node) { String bucket = Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.bindTo(flagSource) .with(FetchVector.Dimension.NODE_TYPE, node.type().name()) .with(FetchVector.Dimension.APPLICATION_ID, node.allocation().map(alloc -> alloc.owner().serializedForm()).orElse(null)) diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java index 508f8cd4c48..aec62ce70d2 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java @@ -28,20 +28,20 @@ public class NodesResponseTest { public void node_archive_url() { ApplicationId app = ApplicationId.from("vespa", "music", "main"); // Flag not set, no archive url - assertNodeArchiveUrl(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); - assertNodeArchiveUrl(null, "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); + assertNodeArchiveUri(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); + assertNodeArchiveUri(null, "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); flagSource.withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "vespa-data-bucket"); // Flag is set, but node not allocated, only sync non-tenant nodes - assertNodeArchiveUrl(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, null); - assertNodeArchiveUrl("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, null); + assertNodeArchiveUri(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, null); + assertNodeArchiveUri("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, null); // Flag is set and node is allocated - assertNodeArchiveUrl("s3://vespa-data-bucket/vespa/music/main/h432a/", "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); - assertNodeArchiveUrl("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); + assertNodeArchiveUri("s3://vespa-data-bucket/vespa/music/main/h432a/", "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); + assertNodeArchiveUri("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); } - private void assertNodeArchiveUrl(String archiveUrl, String hostname, NodeType type, ApplicationId appId) { + private void assertNodeArchiveUri(String archiveUrl, String hostname, NodeType type, ApplicationId appId) { Node.Builder nodeBuilder = Node.create("id", hostname, new Flavor(NodeResources.unspecified()), Node.State.parked, type); Optional.ofNullable(appId) .map(app -> new Allocation(app, @@ -51,6 +51,6 @@ public class NodesResponseTest { false)) .ifPresent(nodeBuilder::allocation); - assertEquals(archiveUrl, NodesResponse.nodeArchiveUrl(flagSource, nodeBuilder.build()).orElse(null)); + assertEquals(archiveUrl, NodesResponse.nodeArchiveUri(flagSource, nodeBuilder.build()).orElse(null)); } } \ No newline at end of file -- cgit v1.2.3 From 5f26c3f9e61ba5d03d3f397f78033fae7261775f Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Fri, 19 Feb 2021 09:13:53 +0100 Subject: nodeArchiveUri -> archiveUri --- .../hosted/provision/restapi/NodesResponse.java | 5 +++-- .../hosted/provision/restapi/NodesResponseTest.java | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'node-repository') diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java index 52625fe113a..58e0e31d2bb 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java @@ -178,7 +178,7 @@ class NodesResponse extends SlimeJsonResponse { node.reports().toSlime(object, "reports"); node.modelName().ifPresent(modelName -> object.setString("modelName", modelName)); node.switchHostname().ifPresent(switchHostname -> object.setString("switchHostname", switchHostname)); - nodeArchiveUri(nodeRepository.flagSource(), node).ifPresent(url -> object.setString("nodeArchiveUri", url)); + archiveUri(nodeRepository.flagSource(), node).ifPresent(uri -> object.setString("archiveUri", uri)); } private void toSlime(ApplicationId id, Cursor object) { @@ -233,7 +233,8 @@ class NodesResponse extends SlimeJsonResponse { return path.substring(lastSlash+1); } - static Optional nodeArchiveUri(FlagSource flagSource, Node node) { + // TODO (freva): Store this in Application or Node + static Optional archiveUri(FlagSource flagSource, Node node) { String bucket = Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.bindTo(flagSource) .with(FetchVector.Dimension.NODE_TYPE, node.type().name()) .with(FetchVector.Dimension.APPLICATION_ID, node.allocation().map(alloc -> alloc.owner().serializedForm()).orElse(null)) diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java index aec62ce70d2..021afd0df7c 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponseTest.java @@ -25,23 +25,23 @@ public class NodesResponseTest { private final InMemoryFlagSource flagSource = new InMemoryFlagSource(); @Test - public void node_archive_url() { + public void archive_uri() { ApplicationId app = ApplicationId.from("vespa", "music", "main"); - // Flag not set, no archive url - assertNodeArchiveUri(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); - assertNodeArchiveUri(null, "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); + // Flag not set, no archive uri + assertArchiveUri(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); + assertArchiveUri(null, "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); flagSource.withStringFlag(Flags.SYNC_HOST_LOGS_TO_S3_BUCKET.id(), "vespa-data-bucket"); // Flag is set, but node not allocated, only sync non-tenant nodes - assertNodeArchiveUri(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, null); - assertNodeArchiveUri("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, null); + assertArchiveUri(null, "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, null); + assertArchiveUri("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, null); // Flag is set and node is allocated - assertNodeArchiveUri("s3://vespa-data-bucket/vespa/music/main/h432a/", "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); - assertNodeArchiveUri("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); + assertArchiveUri("s3://vespa-data-bucket/vespa/music/main/h432a/", "h432a.prod.us-south-1.vespa.domain.tld", NodeType.tenant, app); + assertArchiveUri("s3://vespa-data-bucket/hosted-vespa/cfg1/", "cfg1.prod.us-south-1.vespa.domain.tld", NodeType.config, app); } - private void assertNodeArchiveUri(String archiveUrl, String hostname, NodeType type, ApplicationId appId) { + private void assertArchiveUri(String archiveUri, String hostname, NodeType type, ApplicationId appId) { Node.Builder nodeBuilder = Node.create("id", hostname, new Flavor(NodeResources.unspecified()), Node.State.parked, type); Optional.ofNullable(appId) .map(app -> new Allocation(app, @@ -51,6 +51,6 @@ public class NodesResponseTest { false)) .ifPresent(nodeBuilder::allocation); - assertEquals(archiveUrl, NodesResponse.nodeArchiveUri(flagSource, nodeBuilder.build()).orElse(null)); + assertEquals(archiveUri, NodesResponse.archiveUri(flagSource, nodeBuilder.build()).orElse(null)); } } \ No newline at end of file -- cgit v1.2.3