diff options
author | jonmv <venstad@gmail.com> | 2022-04-08 22:26:37 +0200 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-04-08 22:26:37 +0200 |
commit | 1c27950698237c7ebe0f8ea7ed5848889d6b4759 (patch) | |
tree | 6748bfa41fac16ad9b22d0afba4d150b44414542 /controller-api | |
parent | c5c330f63efb47dad355860db70bf3a89a737970 (diff) |
Revert "Merge pull request #22068 from vespa-engine/jonmv/unify-hostname-classes"
This reverts commit 8aa4c83df5ce7843c040afa41706fcc7c3afd030, reversing
changes made to f95ad44fae879da9db19f73eabe62c53baeb0c36.
Diffstat (limited to 'controller-api')
11 files changed, 37 insertions, 32 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/EnvironmentResource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/EnvironmentResource.java index 389cda605af..77b8118784a 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/EnvironmentResource.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/application/v4/EnvironmentResource.java @@ -2,10 +2,10 @@ package com.yahoo.vespa.hosted.controller.api.application.v4; import com.fasterxml.jackson.databind.JsonNode; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.hosted.controller.api.application.v4.model.InstanceInformation; import com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId; import com.yahoo.vespa.hosted.controller.api.identifiers.EnvironmentId; +import com.yahoo.vespa.hosted.controller.api.identifiers.Hostname; import com.yahoo.vespa.hosted.controller.api.identifiers.InstanceId; import com.yahoo.vespa.hosted.controller.api.identifiers.RegionId; import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId; @@ -51,7 +51,7 @@ public interface EnvironmentResource { @PathParam("environmentId") EnvironmentId environmentId, @PathParam("regionId") RegionId regionId, @PathParam("instanceId") InstanceId instanceId, - @QueryParam("hostname") HostName hostname); + @QueryParam("hostname") Hostname hostname); @GET @Path("{environmentId}/region/{regionId}/instance/{instanceId}") diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/Hostname.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/Hostname.java new file mode 100644 index 00000000000..fc46c92189d --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/Hostname.java @@ -0,0 +1,13 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.identifiers; + +/** + * @author smorgrav + */ +public class Hostname extends Identifier { + + public Hostname(String hostname) { + super(hostname); + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java index 3ac289a06b1..ecd58bc292c 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/MockResourceTagger.java @@ -8,6 +8,7 @@ import com.yahoo.config.provision.zone.ZoneId; import java.util.HashMap; import java.util.Map; +import java.util.Optional; /** * @author olaa diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java index de40344c1c9..18be3a414a5 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/ResourceTagger.java @@ -6,6 +6,7 @@ import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneApi; import java.util.Map; +import java.util.Optional; /** * @author olaa diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java index c5d3fd1374f..d82b9c97187 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/Node.java @@ -530,7 +530,7 @@ public class Node { } public Builder hostname(String hostname) { - return hostname(HostName.of(hostname)); + return hostname(HostName.from(hostname)); } public Builder hostname(HostName hostname) { @@ -539,7 +539,7 @@ public class Node { } public Builder parentHostname(String parentHostname) { - return parentHostname(HostName.of(parentHostname)); + return parentHostname(HostName.from(parentHostname)); } public Builder parentHostname(HostName parentHostname) { diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java index 9d6fe07e91c..0f410ede864 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/TesterCloud.java @@ -1,11 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.deployment; -import ai.vespa.http.DomainName; +import com.yahoo.config.provision.HostName; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; -import java.net.InetAddress; import java.net.URI; import java.util.List; import java.util.Optional; @@ -33,10 +32,10 @@ public interface TesterCloud { boolean testerReady(DeploymentId deploymentId); /** Returns the IP address of the given host name, if any. */ - Optional<InetAddress> resolveHostName(DomainName hostname); + Optional<String> resolveHostName(HostName hostname); /** Returns the host name of the given CNAME, if any. */ - Optional<DomainName> resolveCname(DomainName hostName); + Optional<HostName> resolveCname(HostName hostName); /** Returns the test report as JSON if available */ Optional<TestReport> getTestReport(DeploymentId deploymentId); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTarget.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTarget.java index 04e264651a6..eeac395e8e1 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTarget.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTarget.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.dns; -import ai.vespa.http.DomainName; +import com.yahoo.config.provision.HostName; import java.util.Objects; @@ -12,11 +12,11 @@ import java.util.Objects; */ public abstract class AliasTarget { - private final DomainName name; + private final HostName name; private final String dnsZone; private final String id; - public AliasTarget(DomainName name, String dnsZone, String id) { + public AliasTarget(HostName name, String dnsZone, String id) { this.name = Objects.requireNonNull(name, "name must be non-null"); this.dnsZone = Objects.requireNonNull(dnsZone, "dnsZone must be non-null"); this.id = Objects.requireNonNull(id, "id must be non-null"); @@ -28,7 +28,7 @@ public abstract class AliasTarget { } /** DNS name this points to */ - public final DomainName name() { + public final HostName name() { return name; } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/LatencyAliasTarget.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/LatencyAliasTarget.java index b8cd1e89cdc..170cad8cd5b 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/LatencyAliasTarget.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/LatencyAliasTarget.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.dns; -import ai.vespa.http.DomainName; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneId; @@ -16,7 +15,7 @@ public class LatencyAliasTarget extends AliasTarget { private final ZoneId zone; - public LatencyAliasTarget(DomainName name, String dnsZone, ZoneId zone) { + public LatencyAliasTarget(HostName name, String dnsZone, ZoneId zone) { super(name, dnsZone, zone.value()); this.zone = Objects.requireNonNull(zone); } @@ -60,7 +59,7 @@ public class LatencyAliasTarget extends AliasTarget { if (!"latency".equals(parts[0])) { throw new IllegalArgumentException("Unexpected type '" + parts[0] + "'"); } - return new LatencyAliasTarget(HostName.of(parts[1]), parts[2], ZoneId.from(parts[3])); + return new LatencyAliasTarget(HostName.from(parts[1]), parts[2], ZoneId.from(parts[3])); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/WeightedAliasTarget.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/WeightedAliasTarget.java index e7a46de75bc..963cf74b948 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/WeightedAliasTarget.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/WeightedAliasTarget.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.dns; -import ai.vespa.http.DomainName; import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.zone.ZoneId; @@ -19,7 +18,7 @@ public class WeightedAliasTarget extends AliasTarget { private final long weight; - public WeightedAliasTarget(DomainName name, String dnsZone, ZoneId zone, long weight) { + public WeightedAliasTarget(HostName name, String dnsZone, ZoneId zone, long weight) { super(name, dnsZone, zone.value()); this.weight = weight; if (weight < 0) throw new IllegalArgumentException("Weight cannot be negative"); @@ -64,7 +63,7 @@ public class WeightedAliasTarget extends AliasTarget { if (!"weighted".equals(parts[0])) { throw new IllegalArgumentException("Unexpected type '" + parts[0] + "'"); } - return new WeightedAliasTarget(HostName.of(parts[1]), parts[2], ZoneId.from(parts[3]), + return new WeightedAliasTarget(HostName.from(parts[1]), parts[2], ZoneId.from(parts[3]), Long.parseLong(parts[4])); } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java index 63c2388b461..cf6b592b7a5 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockTesterCloud.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.stubs; -import ai.vespa.http.DomainName; +import com.yahoo.config.provision.HostName; import com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId; import com.yahoo.vespa.hosted.controller.api.integration.LogEntry; import com.yahoo.vespa.hosted.controller.api.integration.deployment.TestReport; @@ -10,9 +10,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.dns.NameService; import com.yahoo.vespa.hosted.controller.api.integration.dns.Record; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName; -import java.net.InetAddress; import java.net.URI; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -59,20 +57,15 @@ public class MockTesterCloud implements TesterCloud { } @Override - public Optional<InetAddress> resolveHostName(DomainName hostname) { - try { - return Optional.of(InetAddress.getByAddress(new byte[]{ 1, 2, 3, 4 })); - } - catch (UnknownHostException e) { - throw new IllegalStateException("should not happen"); - } + public Optional<String> resolveHostName(HostName hostname) { + return Optional.of("1.2.3.4"); } @Override - public Optional<DomainName> resolveCname(DomainName hostName) { + public Optional<HostName> resolveCname(HostName hostName) { return nameService.findRecords(Record.Type.CNAME, RecordName.from(hostName.value())).stream() .findFirst() - .map(record -> DomainName.of(record.data().asString().substring(0, record.data().asString().length() - 1))); + .map(record -> HostName.from(record.data().asString().substring(0, record.data().asString().length() - 1))); } @Override diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTargetTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTargetTest.java index 35d2ad1ffca..ff0fd9e460f 100644 --- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTargetTest.java +++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/integration/dns/AliasTargetTest.java @@ -18,8 +18,8 @@ public class AliasTargetTest { @Test public void packing() { List<AliasTarget> tests = List.of( - new LatencyAliasTarget(HostName.of("foo.example.com"), "dns-zone-1", ZoneId.from("prod.us-north-1")), - new WeightedAliasTarget(HostName.of("bar.example.com"), "dns-zone-2", ZoneId.from("prod.us-north-2"), 50) + new LatencyAliasTarget(HostName.from("foo.example.com"), "dns-zone-1", ZoneId.from("prod.us-north-1")), + new WeightedAliasTarget(HostName.from("bar.example.com"), "dns-zone-2", ZoneId.from("prod.us-north-2"), 50) ); for (var target : tests) { AliasTarget unpacked = AliasTarget.unpack(target.pack()); |