diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2023-03-30 19:02:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-30 19:02:20 +0200 |
commit | ce7f308e31ef11a724e23e33719ba44ca6bb494f (patch) | |
tree | 3abc0b5b33f27ea4d4bdbc2935854040fc495b63 | |
parent | f9e1218c15bb3699603ad8137ab45d799054f25c (diff) | |
parent | f2f13207ae19d3b7cb42809a7a3362fac11219a3 (diff) |
Merge pull request #26643 from vespa-engine/jonmv/domain-name-in-duper-model
Use DomainName instead of the stricter HostName in duper-model
20 files changed, 76 insertions, 87 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java index 178ea6ed514..35b2fef2c78 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java @@ -1,14 +1,14 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.provisioning; -import com.yahoo.component.annotation.Inject; +import ai.vespa.http.DomainName; import com.yahoo.component.Version; +import com.yahoo.component.annotation.Inject; import com.yahoo.config.provision.ActivationContext; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationTransaction; import com.yahoo.config.provision.Deployment; import com.yahoo.config.provision.HostFilter; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.InfraDeployer; import com.yahoo.config.provision.NodeType; @@ -116,7 +116,7 @@ public class InfraDeployerImpl implements InfraDeployer { duperModel.infraApplicationActivated( application.getApplicationId(), - hostSpecs.stream().map(HostSpec::hostname).map(HostName::of).toList()); + hostSpecs.stream().map(HostSpec::hostname).map(DomainName::of).toList()); logger.log(Level.FINE, () -> generateActivationLogMessage(hostSpecs, application.getApplicationId())); } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java index 15126ed5845..06ce08df8c3 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java @@ -1,9 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.testutils; +import ai.vespa.http.DomainName; import com.yahoo.component.annotation.Inject; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.service.monitor.DuperModelInfraApi; import com.yahoo.vespa.service.monitor.InfraApplicationApi; @@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap; public class MockDuperModel implements DuperModelInfraApi { private final Map<ApplicationId, InfraApplicationApi> supportedInfraApps = new HashMap<>(); - private final ConcurrentHashMap<ApplicationId, List<HostName>> activeApps = new ConcurrentHashMap<>(); + private final ConcurrentHashMap<ApplicationId, List<DomainName>> activeApps = new ConcurrentHashMap<>(); @Inject public MockDuperModel() { @@ -46,12 +46,12 @@ public class MockDuperModel implements DuperModelInfraApi { return activeApps.containsKey(applicationId); } - public List<HostName> hostnamesOf(ApplicationId applicationId) { + public List<DomainName> hostnamesOf(ApplicationId applicationId) { return activeApps.getOrDefault(applicationId, List.of()); } @Override - public void infraApplicationActivated(ApplicationId applicationId, List<HostName> hostnames) { + public void infraApplicationActivated(ApplicationId applicationId, List<DomainName> hostnames) { activeApps.put(applicationId, hostnames); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java index 58f4be18992..aaa4bffc000 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java @@ -1,6 +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.provision.maintenance; +import ai.vespa.http.DomainName; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; @@ -268,7 +269,7 @@ public class RetiredExpirerTest { private Set<String> configServerHostnames(MockDuperModel duperModel) { return duperModel.hostnamesOf(new ConfigServerApplication().getApplicationId()).stream() - .map(com.yahoo.config.provision.HostName::value) + .map(DomainName::value) .collect(Collectors.toSet()); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java index 9cd5adef5f4..7763459dd92 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java @@ -1,11 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.provisioning; +import ai.vespa.http.DomainName; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationTransaction; import com.yahoo.config.provision.ClusterMembership; import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.HostSpec; import com.yahoo.config.provision.NodeType; import com.yahoo.config.provision.Provisioner; @@ -133,7 +133,7 @@ public class InfraDeployerImplTest { @SuppressWarnings("unchecked") private void verifyActivated(String... hostnames) { verify(duperModelInfraApi).infraApplicationActivated( - eq(application.getApplicationId()), eq(Stream.of(hostnames).map(HostName::of).toList())); + eq(application.getApplicationId()), eq(Stream.of(hostnames).map(DomainName::of).toList())); ArgumentMatcher<ApplicationTransaction> transactionMatcher = t -> { assertEquals(application.getApplicationId(), t.application()); return true; diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java index 323ae678b0b..73774321ffb 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorTest.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.orchestrator; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.SuperModel; import com.yahoo.config.model.api.SuperModelListener; import com.yahoo.config.model.api.SuperModelProvider; @@ -87,9 +88,9 @@ public class OrchestratorTest { // There is one config server application with 3 nodes ApplicationId applicationId = new ConfigServerApplication().getApplicationId(); - var cfg1 = com.yahoo.config.provision.HostName.of("cfg1"); - var cfg2 = com.yahoo.config.provision.HostName.of("cfg2"); - var cfg3 = com.yahoo.config.provision.HostName.of("cfg3"); + var cfg1 = DomainName.of("cfg1"); + var cfg2 = DomainName.of("cfg2"); + var cfg3 = DomainName.of("cfg3"); duperModelManager.infraApplicationActivated(applicationId, List.of(cfg1, cfg2, cfg3)); duperModelManager.infraApplicationsIsNowComplete(); @@ -135,7 +136,7 @@ public class OrchestratorTest { // etc (should be the same as for cfg1) } - private HostName toApplicationModelHostName(com.yahoo.config.provision.HostName hostname) { + private HostName toApplicationModelHostName(DomainName hostname) { return new HostName(hostname.value()); } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java index 3a9c2b1f1e7..d76b4ecc0b5 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModel.java @@ -1,10 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.duper; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; import java.util.logging.Level; import com.yahoo.vespa.service.monitor.DuperModelListener; @@ -26,8 +26,8 @@ public class DuperModel { private static Logger logger = Logger.getLogger(DuperModel.class.getName()); private final Map<ApplicationId, ApplicationInfo> applicationsById = new HashMap<>(); - private final Map<HostName, ApplicationId> idsByHostname = new HashMap<>(); - private final Map<ApplicationId, HashSet<HostName>> hostnamesById = new HashMap<>(); + private final Map<DomainName, ApplicationId> idsByHostname = new HashMap<>(); + private final Map<ApplicationId, HashSet<DomainName>> hostnamesById = new HashMap<>(); private final List<DuperModelListener> listeners = new ArrayList<>(); private boolean isComplete = false; @@ -67,7 +67,7 @@ public class DuperModel { return Optional.ofNullable(applicationsById.get(applicationId)); } - public Optional<ApplicationInfo> getApplicationInfo(HostName hostName) { + public Optional<ApplicationInfo> getApplicationInfo(DomainName hostName) { return Optional.ofNullable(idsByHostname.get(hostName)).map(applicationsById::get); } @@ -76,12 +76,12 @@ public class DuperModel { } /** Note: Returns an empty set for unknown application. */ - public Set<HostName> getHostnames(ApplicationId applicationId) { - HashSet<HostName> set = hostnamesById.get(applicationId); + public Set<DomainName> getHostnames(ApplicationId applicationId) { + HashSet<DomainName> set = hostnamesById.get(applicationId); return set == null ? Set.of() : Set.copyOf(set); } - public Optional<ApplicationId> getApplicationId(HostName hostname) { + public Optional<ApplicationId> getApplicationId(DomainName hostname) { return Optional.ofNullable(idsByHostname.get(hostname)); } @@ -103,7 +103,7 @@ public class DuperModel { } public void remove(ApplicationId applicationId) { - Set<HostName> hostnames = hostnamesById.remove(applicationId); + Set<DomainName> hostnames = hostnamesById.remove(applicationId); if (hostnames != null) { hostnames.forEach(idsByHostname::remove); } @@ -117,11 +117,11 @@ public class DuperModel { /** Update hostnamesById and idsByHostname based on a new applicationInfo. */ private void updateHostnameVsIdMaps(ApplicationInfo applicationInfo, ApplicationId id) { - Set<HostName> removedHosts = new HashSet<>(hostnamesById.computeIfAbsent(id, k -> new HashSet<>())); + Set<DomainName> removedHosts = new HashSet<>(hostnamesById.computeIfAbsent(id, k -> new HashSet<>())); applicationInfo.getModel().getHosts().stream() .map(HostInfo::getHostname) - .map(HostName::of) + .map(DomainName::of) .forEach(hostname -> { if (!removedHosts.remove(hostname)) { // hostname has been added @@ -135,7 +135,7 @@ public class DuperModel { logger.log(Level.WARNING, hostname + " has been reassigned from " + previousId.toFullString() + " to " + id.toFullString()); - Set<HostName> previousHostnames = hostnamesById.get(previousId); + Set<DomainName> previousHostnames = hostnamesById.get(previousId); if (previousHostnames != null) { previousHostnames.remove(hostname); } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java index b8c980a8760..400c4f4b907 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/DuperModelManager.java @@ -1,14 +1,14 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.duper; -import com.yahoo.component.annotation.Inject; +import ai.vespa.http.DomainName; import com.yahoo.cloud.config.ConfigserverConfig; +import com.yahoo.component.annotation.Inject; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.SuperModel; import com.yahoo.config.model.api.SuperModelListener; import com.yahoo.config.model.api.SuperModelProvider; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.service.monitor.CriticalRegion; import com.yahoo.vespa.service.monitor.DuperModelInfraApi; import com.yahoo.vespa.service.monitor.DuperModelListener; @@ -133,7 +133,7 @@ public class DuperModelManager implements DuperModelProvider, DuperModelInfraApi } @Override - public void infraApplicationActivated(ApplicationId applicationId, List<HostName> hostnames) { + public void infraApplicationActivated(ApplicationId applicationId, List<DomainName> hostnames) { InfraApplication application = supportedInfraApplications.get(applicationId); if (application == null) { throw new IllegalArgumentException("There is no infrastructure application with ID '" + applicationId + "'"); @@ -172,7 +172,7 @@ public class DuperModelManager implements DuperModelProvider, DuperModelInfraApi return lockedSupplier(() -> duperModel.getApplicationInfo(applicationId)); } - public Optional<ApplicationInfo> getApplicationInfo(HostName hostname) { + public Optional<ApplicationInfo> getApplicationInfo(DomainName hostname) { return lockedSupplier(() -> duperModel.getApplicationInfo(hostname)); } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java index e82e2cc0265..07f9d7bddc5 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/duper/InfraApplication.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.duper; +import ai.vespa.http.DomainName; import com.yahoo.component.Version; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.HostInfo; @@ -9,7 +10,6 @@ import com.yahoo.config.model.api.ServiceInfo; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Capacity; import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.Zone; import com.yahoo.vespa.applicationmodel.ApplicationInstanceId; import com.yahoo.vespa.applicationmodel.ClusterId; @@ -93,12 +93,12 @@ public abstract class InfraApplication implements InfraApplicationApi { return new TenantId(application.id().tenant().value()); } - public ApplicationInfo makeApplicationInfo(List<HostName> hostnames) { + public ApplicationInfo makeApplicationInfo(List<DomainName> hostnames) { List<HostInfo> hostInfos = hostnames.stream().map(this::makeHostInfo).toList(); return new ApplicationInfo(application.id(), 0, new HostsModel(hostInfos)); } - private HostInfo makeHostInfo(HostName hostname) { + private HostInfo makeHostInfo(DomainName hostname) { PortInfo portInfo = new PortInfo(healthPort, StateV1HealthModel.HTTP_HEALTH_PORT_TAGS); Map<String, String> properties = new HashMap<>(); @@ -116,7 +116,7 @@ public abstract class InfraApplication implements InfraApplicationApi { return new HostInfo(hostname.value(), Collections.singletonList(serviceInfo)); } - public ConfigId configIdFor(HostName hostname) { + public ConfigId configIdFor(DomainName hostname) { // Not necessarily unique, but service monitor doesn't require it to be unique. return new ConfigId(String.format("%s/%s", clusterSpecId.value(), prefixTo(hostname.value(), '.'))); } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthEndpoint.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthEndpoint.java index a654a4557ef..1d832cc0eec 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthEndpoint.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthEndpoint.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.service.health; -import com.yahoo.config.provision.HostName; +import ai.vespa.http.DomainName; import com.yahoo.vespa.service.executor.RunletExecutor; import com.yahoo.vespa.service.monitor.ServiceId; @@ -22,7 +22,7 @@ class StateV1HealthEndpoint implements HealthEndpoint { private final RunletExecutor executor; StateV1HealthEndpoint(ServiceId serviceId, - HostName hostname, + DomainName hostname, int port, Duration delay, Duration requestTimeout, diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java index 3391bbcf82a..3969ef141bd 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/health/StateV1HealthModel.java @@ -1,11 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.health; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.model.api.PortInfo; import com.yahoo.config.model.api.ServiceInfo; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.service.executor.RunletExecutor; import com.yahoo.vespa.service.model.ApplicationInstanceGenerator; import com.yahoo.vespa.service.monitor.ServiceId; @@ -45,7 +45,7 @@ public class StateV1HealthModel implements AutoCloseable { Map<ServiceId, HealthEndpoint> endpoints = new HashMap<>(); for (HostInfo hostInfo : application.getModel().getHosts()) { - HostName hostname = HostName.of(hostInfo.getHostname()); + DomainName hostname = DomainName.of(hostInfo.getHostname()); for (ServiceInfo serviceInfo : hostInfo.getServices()) { ServiceId serviceId = ApplicationInstanceGenerator.getServiceId(application, serviceInfo); for (PortInfo portInfo : serviceInfo.getPorts()) { diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorImpl.java b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorImpl.java index 815f8de26b4..53db7cc135c 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorImpl.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/model/ServiceMonitorImpl.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.model; +import ai.vespa.http.DomainName; import com.yahoo.component.annotation.Inject; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.provision.ApplicationId; @@ -68,7 +69,7 @@ public class ServiceMonitorImpl implements ServiceMonitor, AntiServiceMonitor { @Override public Optional<ApplicationInstanceReference> getApplicationInstanceReference(HostName hostname) { - return duperModelManager.getApplicationInfo(toConfigProvisionHostName(hostname)) + return duperModelManager.getApplicationInfo(DomainName.of(hostname.s())) .map(ApplicationInfo::getApplicationId) .map(modelGenerator::toApplicationInstanceReference); } @@ -113,11 +114,7 @@ public class ServiceMonitorImpl implements ServiceMonitor, AntiServiceMonitor { } private Optional<ApplicationInfo> getApplicationInfo(HostName hostname) { - return duperModelManager.getApplicationInfo(toConfigProvisionHostName(hostname)); + return duperModelManager.getApplicationInfo(DomainName.of(hostname.s())); } - /** The duper model uses HostName from config.provision. */ - private static com.yahoo.config.provision.HostName toConfigProvisionHostName(HostName hostname) { - return com.yahoo.config.provision.HostName.of(hostname.s()); - } } diff --git a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/DuperModelInfraApi.java b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/DuperModelInfraApi.java index 91782d5a582..783f0a27e51 100644 --- a/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/DuperModelInfraApi.java +++ b/service-monitor/src/main/java/com/yahoo/vespa/service/monitor/DuperModelInfraApi.java @@ -1,8 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.monitor; +import ai.vespa.http.DomainName; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; import java.util.List; import java.util.Optional; @@ -24,7 +24,7 @@ public interface DuperModelInfraApi { boolean infraApplicationIsActive(ApplicationId applicationId); /** Update the DuperModel: A supported infrastructure application has been (re)activated or is active. */ - void infraApplicationActivated(ApplicationId applicationId, List<HostName> hostnames); + void infraApplicationActivated(ApplicationId applicationId, List<DomainName> hostnames); /** Update the DuperModel: A supported infrastructure application has been removed or is not active. */ void infraApplicationRemoved(ApplicationId applicationId); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java index 6cf7d4d9f26..ad7f0f188c0 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelManagerTest.java @@ -1,17 +1,16 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.duper; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.SuperModel; import com.yahoo.config.model.api.SuperModelListener; import com.yahoo.config.model.api.SuperModelProvider; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; import org.junit.Test; import org.mockito.ArgumentCaptor; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import static com.yahoo.vespa.service.duper.DuperModelManager.configServerApplication; @@ -64,7 +63,7 @@ public class DuperModelManagerTest { makeManager(false); ApplicationId id = proxyHostApplication.getApplicationId(); - List<HostName> proxyHostHosts = Stream.of("proxyhost1", "proxyhost2").map(HostName::of).toList(); + List<DomainName> proxyHostHosts = Stream.of("proxyhost1", "proxyhost2").map(DomainName::of).toList(); verify(duperModel, times(0)).add(any()); manager.infraApplicationActivated(id, proxyHostHosts); verify(duperModel, times(1)).add(any()); @@ -91,12 +90,12 @@ public class DuperModelManagerTest { } private void testEnabledConfigServerLikeInfraApplication(ApplicationId firstId, ApplicationId secondId) { - List<HostName> hostnames1 = Stream.of("node11", "node12").map(HostName::of).toList(); + List<DomainName> hostnames1 = Stream.of("node11", "node12").map(DomainName::of).toList(); manager.infraApplicationActivated(firstId, hostnames1); verify(duperModel, times(1)).add(any()); // Adding the second config server like application will be ignored - List<HostName> hostnames2 = Stream.of("node21", "node22").map(HostName::of).toList(); + List<DomainName> hostnames2 = Stream.of("node21", "node22").map(DomainName::of).toList(); assertThrows(IllegalArgumentException.class, () -> manager.infraApplicationActivated(secondId, hostnames2)); verify(duperModel, times(1)).add(any()); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java index 73a49ca8717..568dc3640e2 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/duper/DuperModelTest.java @@ -1,11 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.duper; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.model.api.Model; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.service.monitor.DuperModelListener; import org.junit.Before; import org.junit.Test; @@ -14,7 +14,6 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.junit.Assert.assertEquals; @@ -34,12 +33,12 @@ public class DuperModelTest { private final ApplicationId id1 = ApplicationId.fromSerializedForm("tenant:app1:default"); private final ApplicationInfo application1 = mock(ApplicationInfo.class); - private final HostName hostname1_1 = HostName.of("hostname1-1"); - private final HostName hostname1_2 = HostName.of("hostname1-2"); + private final DomainName hostname1_1 = DomainName.of("hostname1-1"); + private final DomainName hostname1_2 = DomainName.of("hostname1-2"); private final ApplicationId id2 = ApplicationId.fromSerializedForm("tenant:app2:default"); private final ApplicationInfo application2 = mock(ApplicationInfo.class); - private final HostName hostname2_1 = HostName.of("hostname2-1"); + private final DomainName hostname2_1 = DomainName.of("hostname2-1"); private final DuperModelListener listener1 = mock(DuperModelListener.class); @@ -49,7 +48,7 @@ public class DuperModelTest { setUpApplication(id2, application2, hostname2_1); } - private void setUpApplication(ApplicationId id, ApplicationInfo info, HostName... hostnames) { + private void setUpApplication(ApplicationId id, ApplicationInfo info, DomainName... hostnames) { when(info.getApplicationId()).thenReturn(id); Model model = mock(Model.class); @@ -129,7 +128,7 @@ public class DuperModelTest { addAndVerifyApplication1("host1"); addAndVerifyApplication1("host1", "host2"); addAndVerifyApplication1("host2", "host3"); - assertEquals(Optional.empty(), duperModel.getApplicationId(HostName.of("host1"))); + assertEquals(Optional.empty(), duperModel.getApplicationId(DomainName.of("host1"))); duperModel.remove(id1); assertEquals(0, duperModel.numberOfApplications()); @@ -138,7 +137,7 @@ public class DuperModelTest { } private void addAndVerifyApplication1(String... hostnameStrings) { - HostName[] hostnameArray = Stream.of(hostnameStrings).map(HostName::of).toArray(HostName[]::new); + DomainName[] hostnameArray = Stream.of(hostnameStrings).map(DomainName::of).toArray(DomainName[]::new); setUpApplication(id1, application1, hostnameArray); duperModel.add(application1); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/health/ApplicationHealthMonitorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/ApplicationHealthMonitorTest.java index d99e882985f..9f46b5dfe8f 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/health/ApplicationHealthMonitorTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/ApplicationHealthMonitorTest.java @@ -1,13 +1,13 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.health; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.applicationmodel.ServiceStatus; import com.yahoo.vespa.applicationmodel.ServiceStatusInfo; import com.yahoo.vespa.service.duper.ConfigServerApplication; -import com.yahoo.vespa.service.monitor.ServiceId; import com.yahoo.vespa.service.monitor.ConfigserverUtil; +import com.yahoo.vespa.service.monitor.ServiceId; import org.junit.Test; import java.util.HashMap; @@ -87,7 +87,7 @@ public class ApplicationHealthMonitorTest { return new ServiceId(configServerApplication.getApplicationId(), configServerApplication.getClusterId(), configServerApplication.getServiceType(), - configServerApplication.configIdFor(HostName.of(hostname))); + configServerApplication.configIdFor(DomainName.of(hostname))); } private ServiceStatus getStatus(ApplicationHealthMonitor monitor, String hostname) { @@ -95,7 +95,7 @@ public class ApplicationHealthMonitorTest { configServerApplication.getApplicationId(), configServerApplication.getClusterId(), configServerApplication.getServiceType(), - configServerApplication.configIdFor(HostName.of(hostname))) + configServerApplication.configIdFor(DomainName.of(hostname))) .serviceStatus(); } }
\ No newline at end of file diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java index f7ee64b52a6..f9129b5e4f4 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/HealthMonitorManagerTest.java @@ -1,8 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.health; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.applicationmodel.ServiceStatus; import com.yahoo.vespa.applicationmodel.ServiceStatusInfo; import com.yahoo.vespa.service.duper.ControllerHostApplication; @@ -14,7 +14,6 @@ import org.junit.Before; import org.junit.Test; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.junit.Assert.assertEquals; @@ -48,7 +47,7 @@ public class HealthMonitorManagerTest { public void infrastructureApplication() { ProxyHostApplication proxyHostApplication = new ProxyHostApplication(); when(duperModel.isSupportedInfraApplication(proxyHostApplication.getApplicationId())).thenReturn(true); - List<HostName> hostnames = Stream.of("proxyhost1", "proxyhost2").map(HostName::of).toList(); + List<DomainName> hostnames = Stream.of("proxyhost1", "proxyhost2").map(DomainName::of).toList(); ApplicationInfo proxyHostApplicationInfo = proxyHostApplication.makeApplicationInfo(hostnames); manager.applicationActivated(proxyHostApplicationInfo); @@ -77,7 +76,7 @@ public class HealthMonitorManagerTest { infraApplication.getApplicationId(), infraApplication.getClusterId(), infraApplication.getServiceType(), - infraApplication.configIdFor(HostName.of(hostname))).serviceStatus(); + infraApplication.configIdFor(DomainName.of(hostname))).serviceStatus(); assertEquals(expected, actual); @@ -85,7 +84,7 @@ public class HealthMonitorManagerTest { infraApplication.getApplicationId(), infraApplication.getClusterId(), infraApplication.getServiceType(), - infraApplication.configIdFor(HostName.of(hostname))); + infraApplication.configIdFor(DomainName.of(hostname))); } }
\ No newline at end of file diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java index 18b56f76e88..01b7930a74f 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/health/StateV1HealthModelTest.java @@ -1,10 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.health; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.PortInfo; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.applicationmodel.ClusterId; import com.yahoo.vespa.applicationmodel.ConfigId; import com.yahoo.vespa.applicationmodel.ServiceStatus; @@ -18,7 +18,6 @@ import org.junit.Test; import java.time.Duration; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import static org.junit.Assert.assertEquals; @@ -38,7 +37,7 @@ public class StateV1HealthModelTest { private final Duration requestTimeout = Duration.ofSeconds(2); private final Duration keepAlive = Duration.ofSeconds(3); private final ProxyHostApplication proxyHostApplication = new ProxyHostApplication(); - private final List<HostName> hostnames = Stream.of("host1", "host2").map(HostName::of).toList(); + private final List<DomainName> hostnames = Stream.of("host1", "host2").map(DomainName::of).toList(); private final ApplicationInfo proxyHostApplicationInfo = proxyHostApplication.makeApplicationInfo(hostnames); private final StateV1HealthModel model = new StateV1HealthModel(healthStaleness, requestTimeout, keepAlive, executor); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java index a2532590f52..e85a00d732c 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ApplicationInstanceGeneratorTest.java @@ -1,8 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.model; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; -import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.Zone; import com.yahoo.vespa.applicationmodel.ApplicationInstance; import com.yahoo.vespa.applicationmodel.ServiceStatus; @@ -12,7 +12,6 @@ import com.yahoo.vespa.service.monitor.ServiceStatusProvider; import org.junit.Test; import java.util.List; -import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -34,7 +33,7 @@ public class ApplicationInstanceGeneratorTest { when(statusProvider.getStatus(any(), any(), any(), any())).thenReturn(new ServiceStatusInfo(ServiceStatus.NOT_CHECKED)); Zone zone = mock(Zone.class); ApplicationInfo configServer = configServerApplication.makeApplicationInfo( - configServerList.stream().map(HostName::of).toList()); + configServerList.stream().map(DomainName::of).toList()); ApplicationInstance applicationInstance = new ApplicationInstanceGenerator(configServer, zone) .makeApplicationInstance(statusProvider); diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceHostListenerAdapterTest.java b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceHostListenerAdapterTest.java index c93e4dfb7fe..23422640af9 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceHostListenerAdapterTest.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/model/ServiceHostListenerAdapterTest.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.model; +import ai.vespa.http.DomainName; import com.yahoo.config.model.api.ApplicationInfo; import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.model.api.Model; @@ -100,7 +101,7 @@ public class ServiceHostListenerAdapterTest { } private Optional<ApplicationInfo> getDuperModelApplicationInfo(String hostname) { - return duperModel.getApplicationInfo(com.yahoo.config.provision.HostName.of(hostname)); + return duperModel.getApplicationInfo(DomainName.of(hostname)); } private void removeAndVerify(ApplicationId id, boolean listenerInvoked) { diff --git a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/ConfigserverUtil.java b/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/ConfigserverUtil.java index 498a9dfc15e..d2480cd6520 100644 --- a/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/ConfigserverUtil.java +++ b/service-monitor/src/test/java/com/yahoo/vespa/service/monitor/ConfigserverUtil.java @@ -1,18 +1,18 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.service.monitor; +import ai.vespa.http.DomainName; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.model.api.ApplicationInfo; -import com.yahoo.config.provision.HostName; import com.yahoo.vespa.service.duper.ConfigServerApplication; -import java.util.stream.Collectors; -import java.util.stream.Stream; +import java.util.List; /** * @author hakon */ public class ConfigserverUtil { + /** Create a ConfigserverConfig with the given settings. */ public static ConfigserverConfig create( boolean multitenant, @@ -31,16 +31,10 @@ public class ConfigserverUtil { return create(true, "cfg1", "cfg2", "cfg3"); } - public static ApplicationInfo makeConfigServerApplicationInfo( - String configServerHostname1, - String configServerHostname2, - String configServerHostname3) { - return new ConfigServerApplication().makeApplicationInfo( - Stream.of(configServerHostname1, configServerHostname2, configServerHostname3) - .map(HostName::of).toList()); - } - public static ApplicationInfo makeExampleConfigServer() { - return makeConfigServerApplicationInfo("cfg1", "cfg2", "cfg3"); + return new ConfigServerApplication().makeApplicationInfo(List.of(DomainName.of("cfg1"), + DomainName.of("cfg2"), + DomainName.of("cfg3"))); } + } |