diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2019-09-03 07:53:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 07:53:15 +0200 |
commit | 7e26976e385c864da3b8bebaf63d4648bee694b2 (patch) | |
tree | 571015568355aebe3a1a1e1cc6f3fb7f5765a2fa | |
parent | 8f14e61b4a55d159dac04babd9739115a1ee0a8c (diff) | |
parent | a48167e80d151f5ef47a4564bd7b52ad795a51a5 (diff) |
Merge pull request #10480 from vespa-engine/mpolden/service-registry
Introduce ServiceRegistry in controller
27 files changed, 178 insertions, 117 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java new file mode 100644 index 00000000000..964c2ece524 --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java @@ -0,0 +1,23 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.api.integration; + +import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; +import com.yahoo.vespa.hosted.controller.api.integration.dns.NameService; +import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService; + +/** + * This provides access to all service dependencies of the controller. Implementations of this are responsible for + * constructing and configuring service implementations suitable for use by the controller. + * + * @author mpolden + */ +// TODO(mpolden): Access all services through this +public interface ServiceRegistry { + + ConfigServer configServer(); + + NameService nameService(); + + GlobalRoutingService globalRoutingService(); + +} diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java index 7b0581b8ca9..707da83ac83 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. 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.inject.Inject; @@ -13,8 +13,8 @@ import com.yahoo.vespa.curator.Lock; import com.yahoo.vespa.flags.FlagSource; import com.yahoo.vespa.hosted.controller.api.integration.BuildService; import com.yahoo.vespa.hosted.controller.api.integration.RunDataStore; +import com.yahoo.vespa.hosted.controller.api.integration.ServiceRegistry; import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificateProvider; -import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ApplicationStore; import com.yahoo.vespa.hosted.controller.api.integration.deployment.ArtifactRepository; import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; @@ -22,7 +22,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.maven.MavenRepository; import com.yahoo.vespa.hosted.controller.api.integration.metrics.MetricsService; import com.yahoo.vespa.hosted.controller.api.integration.organization.Mailer; import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient; -import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService; import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator; import com.yahoo.vespa.hosted.controller.api.integration.user.Roles; import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry; @@ -77,7 +76,7 @@ public class Controller extends AbstractComponent { private final JobController jobController; private final Clock clock; private final ZoneRegistry zoneRegistry; - private final ConfigServer configServer; + private final ServiceRegistry serviceRegistry; private final MetricsService metricsService; private final Mailer mailer; private final AuditLogger auditLogger; @@ -86,7 +85,6 @@ public class Controller extends AbstractComponent { private final ApplicationCertificateProvider applicationCertificateProvider; private final MavenRepository mavenRepository; private final MeteringClient meteringClient; - private final GlobalRoutingService globalRoutingService; /** * Creates a controller @@ -95,22 +93,22 @@ public class Controller extends AbstractComponent { */ @Inject public Controller(CuratorDb curator, RotationsConfig rotationsConfig, - ZoneRegistry zoneRegistry, ConfigServer configServer, MetricsService metricsService, + ZoneRegistry zoneRegistry, MetricsService metricsService, RoutingGenerator routingGenerator, AccessControl accessControl, ArtifactRepository artifactRepository, ApplicationStore applicationStore, TesterCloud testerCloud, BuildService buildService, RunDataStore runDataStore, Mailer mailer, FlagSource flagSource, MavenRepository mavenRepository, ApplicationCertificateProvider applicationCertificateProvider, - MeteringClient meteringClient, GlobalRoutingService globalRoutingService) { + MeteringClient meteringClient, ServiceRegistry serviceRegistry) { this(curator, rotationsConfig, zoneRegistry, - configServer, metricsService, routingGenerator, + metricsService, routingGenerator, Clock.systemUTC(), accessControl, artifactRepository, applicationStore, testerCloud, buildService, runDataStore, com.yahoo.net.HostName::getLocalhost, mailer, flagSource, - mavenRepository, applicationCertificateProvider, meteringClient, globalRoutingService); + mavenRepository, applicationCertificateProvider, meteringClient, serviceRegistry); } public Controller(CuratorDb curator, RotationsConfig rotationsConfig, - ZoneRegistry zoneRegistry, ConfigServer configServer, + ZoneRegistry zoneRegistry, MetricsService metricsService, RoutingGenerator routingGenerator, Clock clock, AccessControl accessControl, @@ -118,12 +116,12 @@ public class Controller extends AbstractComponent { BuildService buildService, RunDataStore runDataStore, Supplier<String> hostnameSupplier, Mailer mailer, FlagSource flagSource, MavenRepository mavenRepository, ApplicationCertificateProvider applicationCertificateProvider, MeteringClient meteringClient, - GlobalRoutingService globalRoutingService) { + ServiceRegistry serviceRegistry) { this.hostnameSupplier = Objects.requireNonNull(hostnameSupplier, "HostnameSupplier cannot be null"); this.curator = Objects.requireNonNull(curator, "Curator cannot be null"); this.zoneRegistry = Objects.requireNonNull(zoneRegistry, "ZoneRegistry cannot be null"); - this.configServer = Objects.requireNonNull(configServer, "ConfigServer cannot be null"); + this.serviceRegistry = Objects.requireNonNull(serviceRegistry, "ServiceRegistry cannot be null"); this.metricsService = Objects.requireNonNull(metricsService, "MetricsService cannot be null"); this.clock = Objects.requireNonNull(clock, "Clock cannot be null"); this.mailer = Objects.requireNonNull(mailer, "Mailer cannot be null"); @@ -131,13 +129,12 @@ public class Controller extends AbstractComponent { this.applicationCertificateProvider = Objects.requireNonNull(applicationCertificateProvider); this.mavenRepository = Objects.requireNonNull(mavenRepository, "MavenRepository cannot be null"); this.meteringClient = Objects.requireNonNull(meteringClient, "MeteringClient cannot be null"); - this.globalRoutingService = Objects.requireNonNull(globalRoutingService, "GlobalRoutingSerivce cannot be null"); nameServiceForwarder = new NameServiceForwarder(curator); jobController = new JobController(this, runDataStore, Objects.requireNonNull(testerCloud)); applicationController = new ApplicationController(this, curator, accessControl, Objects.requireNonNull(rotationsConfig, "RotationsConfig cannot be null"), - configServer, + serviceRegistry.configServer(), Objects.requireNonNull(artifactRepository, "ArtifactRepository cannot be null"), Objects.requireNonNull(applicationStore, "ApplicationStore cannot be null"), Objects.requireNonNull(routingGenerator, "RoutingGenerator cannot be null"), @@ -162,6 +159,11 @@ public class Controller extends AbstractComponent { /** Returns the instance controlling deployment jobs. */ public JobController jobController() { return jobController; } + /** Returns the service registry of this */ + public ServiceRegistry serviceRegistry() { + return serviceRegistry; + } + public Mailer mailer() { return mailer; } @@ -171,10 +173,6 @@ public class Controller extends AbstractComponent { return flagSource; } - public GlobalRoutingService globalRoutingService() { - return globalRoutingService; - } - public Clock clock() { return clock; } public ZoneRegistry zoneRegistry() { return zoneRegistry; } @@ -185,14 +183,14 @@ public class Controller extends AbstractComponent { public ApplicationView getApplicationView(String tenantName, String applicationName, String instanceName, String environment, String region) { - return configServer.getApplicationView(tenantName, applicationName, instanceName, environment, region); + return serviceRegistry.configServer().getApplicationView(tenantName, applicationName, instanceName, environment, region); } // TODO: Model the response properly public Map<?,?> getServiceApiResponse(String tenantName, String applicationName, String instanceName, String environment, String region, String serviceName, String restPath) { - return configServer.getServiceApiResponse(tenantName, applicationName, instanceName, environment, region, - serviceName, restPath); + return serviceRegistry.configServer().getServiceApiResponse(tenantName, applicationName, instanceName, environment, region, + serviceName, restPath); } /** Replace the current version status by a new one */ @@ -290,10 +288,6 @@ public class Controller extends AbstractComponent { return metricsService; } - public ConfigServer configServer() { - return configServer; - } - public SystemName system() { return zoneRegistry.system(); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java index 0d6da51c492..9df918e3f20 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.application; import com.yahoo.component.Version; @@ -58,7 +58,7 @@ public enum SystemApplication { if (!hasApplicationPackage()) { return true; } - return controller.configServer().serviceConvergence(new DeploymentId(id(), zone), version) + return controller.serviceRegistry().configServer().serviceConvergence(new DeploymentId(id(), zone), version) .map(ServiceConvergence::converged) .orElse(false); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index 6390a17fd38..2e77aa0c69c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.deployment; import com.google.common.collect.ImmutableList; @@ -342,7 +342,7 @@ public class InternalStepRunner implements StepRunner { } private boolean nodesConverged(ApplicationId id, JobType type, Version target, DualLogger logger) { - List<Node> nodes = controller.configServer().nodeRepository().list(type.zone(controller.system()), id, ImmutableSet.of(active, reserved)); + List<Node> nodes = controller.serviceRegistry().configServer().nodeRepository().list(type.zone(controller.system()), id, ImmutableSet.of(active, reserved)); List<String> statuses = nodes.stream() .map(node -> String.format("%70s: %-16s%-25s%-32s%s", node.hostname(), @@ -361,7 +361,7 @@ public class InternalStepRunner implements StepRunner { } private boolean servicesConverged(ApplicationId id, JobType type, Version platform, DualLogger logger) { - var convergence = controller.configServer().serviceConvergence(new DeploymentId(id, type.zone(controller.system())), + var convergence = controller.serviceRegistry().configServer().serviceConvergence(new DeploymentId(id, type.zone(controller.system())), Optional.of(platform)); if (convergence.isEmpty()) { logger.log("Config status not currently available -- will retry."); @@ -461,7 +461,7 @@ public class InternalStepRunner implements StepRunner { try { logger.log("Copying Vespa log from nodes of " + id.application() + " in " + zone + " ..."); List<LogEntry> entries = new ArrayList<>(); - String logs = IOUtils.readAll(controller.configServer().getLogs(new DeploymentId(id.application(), zone), + String logs = IOUtils.readAll(controller.serviceRegistry().configServer().getLogs(new DeploymentId(id.application(), zone), Collections.emptyMap()), // Get all logs. StandardCharsets.UTF_8); for (String line : logs.split("\n")) { @@ -619,7 +619,7 @@ public class InternalStepRunner implements StepRunner { private Map<ZoneId, List<String>> listClusters(ApplicationId id, Iterable<ZoneId> zones) { ImmutableMap.Builder<ZoneId, List<String>> clusters = ImmutableMap.builder(); for (ZoneId zone : zones) - clusters.put(zone, ImmutableList.copyOf(controller.configServer().getContentClusters(new DeploymentId(id, zone)))); + clusters.put(zone, ImmutableList.copyOf(controller.serviceRegistry().configServer().getContentClusters(new DeploymentId(id, zone)))); return clusters.build(); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index faacc13d3cb..3f808f91310 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.deployment; import com.google.common.collect.ImmutableMap; @@ -377,7 +377,7 @@ public class JobController { public void deactivateTester(TesterId id, JobType type) { try { - controller.configServer().deactivate(new DeploymentId(id.id(), type.zone(controller.system()))); + controller.serviceRegistry().configServer().deactivate(new DeploymentId(id.id(), type.zone(controller.system()))); } catch (NotFoundException ignored) { // Already gone -- great! diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java index 4112d04d627..357076b5f73 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ClusterInfoMaintainer.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.config.provision.ClusterSpec; @@ -37,7 +37,7 @@ public class ClusterInfoMaintainer extends Maintainer { ClusterInfoMaintainer(Controller controller, Duration duration, JobControl jobControl) { super(controller, duration, jobControl); this.controller = controller; - this.nodeRepository = controller.configServer().nodeRepository(); + this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); } private static String clusterId(NodeRepositoryNode node) { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java index 4ef8576066e..7c3188d9d28 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.AbstractComponent; @@ -6,7 +6,6 @@ import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.jdisc.Metric; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.aws.AwsEventFetcher; -import com.yahoo.vespa.hosted.controller.api.integration.dns.NameService; import com.yahoo.vespa.hosted.controller.api.integration.organization.Billing; import com.yahoo.vespa.hosted.controller.api.integration.organization.ContactRetriever; import com.yahoo.vespa.hosted.controller.api.integration.organization.DeploymentIssues; @@ -62,7 +61,6 @@ public class ControllerMaintenance extends AbstractComponent { public ControllerMaintenance(MaintainerConfig maintainerConfig, ApiAuthorityConfig apiAuthorityConfig, Controller controller, CuratorDb curator, JobControl jobControl, Metric metric, DeploymentIssues deploymentIssues, OwnershipIssues ownershipIssues, - NameService nameService, ContactRetriever contactRetriever, CostReportConsumer reportConsumer, MeteringClient meteringClient, @@ -88,7 +86,7 @@ public class ControllerMaintenance extends AbstractComponent { osUpgraders = osUpgraders(controller, jobControl); osVersionStatusUpdater = new OsVersionStatusUpdater(controller, maintenanceInterval, jobControl); contactInformationMaintainer = new ContactInformationMaintainer(controller, Duration.ofHours(12), jobControl, contactRetriever); - nameServiceDispatcher = new NameServiceDispatcher(controller, Duration.ofSeconds(10), jobControl, nameService); + nameServiceDispatcher = new NameServiceDispatcher(controller, Duration.ofSeconds(10), jobControl); costReportMaintainer = new CostReportMaintainer(controller, Duration.ofHours(2), reportConsumer, jobControl, selfHostedCostConfig); resourceMeterMaintainer = new ResourceMeterMaintainer(controller, Duration.ofMinutes(30), jobControl, metric, meteringClient); billingMaintainer = new BillingMaintainer(controller, Duration.ofDays(3), jobControl, billing); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java index 436cb7e634d..20339b814a8 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; import com.google.inject.Inject; @@ -35,7 +35,7 @@ public class CostReportMaintainer extends Maintainer { SelfHostedCostConfig selfHostedCostConfig) { super(controller, interval, jobControl, "CostReportMaintainer", EnumSet.of(SystemName.main)); this.consumer = consumer; - this.nodeRepository = controller.configServer().nodeRepository(); + this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); this.clock = controller.clock(); this.selfHostedCostConfig = selfHostedCostConfig; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/InfrastructureUpgrader.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/InfrastructureUpgrader.java index b8bb9a7ef79..0dd6f0782bf 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/InfrastructureUpgrader.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/InfrastructureUpgrader.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; import com.yahoo.component.Version; @@ -97,7 +97,7 @@ public abstract class InfrastructureUpgrader extends Maintainer { /** Find the minimum value of a version field in a zone */ protected final Optional<Version> minVersion(ZoneApi zone, SystemApplication application, Function<Node, Version> versionField) { try { - return controller().configServer() + return controller().serviceRegistry().configServer() .nodeRepository() .list(zone.getId(), application.id()) .stream() diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcher.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcher.java index d4dc068c71f..00a85bb9e4d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcher.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/NameServiceDispatcher.java @@ -23,16 +23,14 @@ public class NameServiceDispatcher extends Maintainer { private final NameService nameService; private final int requestCount; - public NameServiceDispatcher(Controller controller, Duration interval, JobControl jobControl, - NameService nameService) { - this(controller, interval, jobControl, nameService, defaultRequestCount); + public NameServiceDispatcher(Controller controller, Duration interval, JobControl jobControl) { + this(controller, interval, jobControl, defaultRequestCount); } - public NameServiceDispatcher(Controller controller, Duration interval, JobControl jobControl, - NameService nameService, int requestCount) { + public NameServiceDispatcher(Controller controller, Duration interval, JobControl jobControl, int requestCount) { super(controller, interval, jobControl); this.db = controller.curator(); - this.nameService = nameService; + this.nameService = controller.serviceRegistry().nameService(); this.requestCount = requestCount; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgrader.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgrader.java index 8845f4c652f..0a16377426e 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgrader.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/OsUpgrader.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.maintenance; import com.google.common.collect.ImmutableSet; @@ -43,7 +43,7 @@ public class OsUpgrader extends InfrastructureUpgrader { return; } log.info(String.format("Upgrading OS of %s to version %s in %s in cloud %s", application.id(), target, zone.getId(), zone.getCloudName())); - controller().configServer().nodeRepository().upgradeOs(zone.getId(), application.nodeType(), target); + controller().serviceRegistry().configServer().nodeRepository().upgradeOs(zone.getId(), application.nodeType(), target); } @Override diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java index 703cec348a8..8dba0a3e813 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ResourceMeterMaintainer.java @@ -40,7 +40,7 @@ public class ResourceMeterMaintainer extends Maintainer { MeteringClient meteringClient) { super(controller, interval, jobControl, null, SystemName.all()); this.clock = controller.clock(); - this.nodeRepository = controller.configServer().nodeRepository(); + this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); this.metric = metric; this.meteringClient = meteringClient; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java index ab818a675b0..a0eff95db48 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java @@ -35,7 +35,7 @@ public class RotationStatusUpdater extends Maintainer { public RotationStatusUpdater(Controller controller, Duration interval, JobControl jobControl) { super(controller, interval, jobControl); - this.service = controller.globalRoutingService(); + this.service = controller.serviceRegistry().globalRoutingService(); this.applications = controller.applications(); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPolicies.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPolicies.java index 0734ca4d3e7..b2006c4c1f4 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPolicies.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPolicies.java @@ -74,7 +74,7 @@ public class RoutingPolicies { */ public void refresh(ApplicationId application, DeploymentSpec deploymentSpec, ZoneId zone) { if (!controller.zoneRegistry().zones().directlyRouted().ids().contains(zone)) return; - var lbs = new AllocatedLoadBalancers(application, zone, controller.configServer().getLoadBalancers(application, zone)); + var lbs = new AllocatedLoadBalancers(application, zone, controller.serviceRegistry().configServer().getLoadBalancers(application, zone)); try (var lock = db.lockRoutingPolicies()) { removeObsoleteEndpointsFromDns(lbs, deploymentSpec, lock); storePoliciesOf(lbs, deploymentSpec, lock); 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 a04f9a99ec0..fbc8f06bd38 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 @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.restapi.application; import ai.vespa.hosted.api.Signatures; @@ -380,7 +380,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { private HttpResponse nodes(String tenantName, String applicationName, String instanceName, String environment, String region) { ApplicationId id = ApplicationId.from(tenantName, applicationName, instanceName); ZoneId zone = ZoneId.from(environment, region); - List<Node> nodes = controller.configServer().nodeRepository().list(zone, id); + List<Node> nodes = controller.serviceRegistry().configServer().nodeRepository().list(zone, id); Slime slime = new Slime(); Cursor nodesArray = slime.setObject().setArray("nodes"); @@ -438,7 +438,7 @@ public class ApplicationApiHandler extends LoggingRequestHandler { ApplicationId application = ApplicationId.from(tenantName, applicationName, instanceName); ZoneId zone = ZoneId.from(environment, region); DeploymentId deployment = new DeploymentId(application, zone); - InputStream logStream = controller.configServer().getLogs(deployment, queryParameters); + InputStream logStream = controller.serviceRegistry().configServer().getLogs(deployment, queryParameters); return new HttpResponse(200) { @Override public void render(OutputStream outputStream) throws IOException { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java index bdaa86a59ff..ee633a19bfc 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/cost/CostApiHandler.java @@ -28,7 +28,7 @@ public class CostApiHandler extends LoggingRequestHandler { public CostApiHandler(Context ctx, Controller controller, SelfHostedCostConfig selfHostedCostConfig) { super(ctx); this.controller = controller; - this.nodeRepository = controller.configServer().nodeRepository(); + this.nodeRepository = controller.serviceRegistry().configServer().nodeRepository(); this.selfHostedCostConfig = selfHostedCostConfig; } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiHandler.java index bc360fe3c6f..fde013b223c 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiHandler.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.restapi.os; import com.yahoo.component.Version; @@ -102,7 +102,7 @@ public class OsApiHandler extends AuditLoggingRequestHandler { StringJoiner response = new StringJoiner(", ", "Requested firmware checks in ", "."); for (ZoneId zone : zones) { - controller.configServer().nodeRepository().requestFirmwareCheck(zone); + controller.serviceRegistry().configServer().nodeRepository().requestFirmwareCheck(zone); response.add(zone.value()); } return new MessageResponse(response.toString()); @@ -115,7 +115,7 @@ public class OsApiHandler extends AuditLoggingRequestHandler { StringJoiner response = new StringJoiner(", ", "Cancelled firmware checks in ", "."); for (ZoneId zone : zones) { - controller.configServer().nodeRepository().cancelFirmwareCheck(zone); + controller.serviceRegistry().configServer().nodeRepository().cancelFirmwareCheck(zone); response.add(zone.value()); } return new MessageResponse(response.toString()); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/OsVersionStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/OsVersionStatus.java index f5b9d8263e5..a73a20198f0 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/OsVersionStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/OsVersionStatus.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.versions; import com.google.common.collect.ImmutableMap; @@ -9,7 +9,6 @@ import com.yahoo.config.provision.HostName; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.zone.ZoneApi; import com.yahoo.vespa.hosted.controller.Controller; -import com.yahoo.config.provision.zone.ZoneId; import com.yahoo.vespa.hosted.controller.application.SystemApplication; import com.yahoo.vespa.hosted.controller.maintenance.OsUpgrader; @@ -72,7 +71,7 @@ public class OsVersionStatus { continue; // Avoid querying applications that are not eligible for OS upgrades } for (ZoneApi zone : zonesToUpgrade(controller)) { - controller.configServer().nodeRepository().list(zone.getId(), application.id()).stream() + controller.serviceRegistry().configServer().nodeRepository().list(zone.getId(), application.id()).stream() .filter(node -> OsUpgrader.eligibleForUpgrade(node, application)) .map(node -> new Node(node.hostname(), node.currentOsVersion(), zone.getEnvironment(), zone.getRegionName())) .forEach(node -> { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java index c16cf1e1997..63d470a5b1d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/versions/VersionStatus.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.versions; import com.google.common.collect.ArrayListMultimap; @@ -154,7 +154,7 @@ public class VersionStatus { ListMultimap<Version, HostName> versions = ArrayListMultimap.create(); for (ZoneApi zone : controller.zoneRegistry().zones().controllerUpgraded().zones()) { for (SystemApplication application : SystemApplication.all()) { - List<Node> eligibleForUpgradeApplicationNodes = controller.configServer().nodeRepository() + List<Node> eligibleForUpgradeApplicationNodes = controller.serviceRegistry().configServer().nodeRepository() .list(zone.getId(), application.id()).stream() .filter(SystemUpgrader::eligibleForUpgrade) .collect(Collectors.toList()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java index 3ce3ac5eecb..0cabd2ce63c 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller; import com.yahoo.config.provision.ApplicationId; @@ -27,7 +27,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.dns.Record; import com.yahoo.vespa.hosted.controller.api.integration.dns.RecordName; import com.yahoo.vespa.hosted.controller.api.integration.organization.Contact; import com.yahoo.vespa.hosted.controller.api.integration.organization.MockContactRetriever; -import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService; import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMailer; @@ -45,6 +44,7 @@ import com.yahoo.vespa.hosted.controller.integration.ArtifactRepositoryMock; import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; import com.yahoo.vespa.hosted.controller.integration.MetricsServiceMock; import com.yahoo.vespa.hosted.controller.integration.RoutingGeneratorMock; +import com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock; import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock; import com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer; import com.yahoo.vespa.hosted.controller.persistence.CuratorDb; @@ -79,10 +79,9 @@ public final class ControllerTester { private final AthenzDbMock athenzDb; private final ManualClock clock; - private final ConfigServerMock configServer; private final ZoneRegistryMock zoneRegistry; + private final ServiceRegistryMock serviceRegistry; private final CuratorDb curator; - private final MemoryNameService nameService; private final RotationsConfig rotationsConfig; private final ArtifactRepositoryMock artifactRepository; private final ApplicationStoreMock applicationStore; @@ -90,16 +89,16 @@ public final class ControllerTester { private final MetricsServiceMock metricsService; private final RoutingGeneratorMock routingGenerator; private final MockContactRetriever contactRetriever; - private final MemoryGlobalRoutingService globalRoutingService; private Controller controller; public ControllerTester(ManualClock clock, RotationsConfig rotationsConfig, MockCuratorDb curatorDb, MetricsServiceMock metricsService) { - this(new AthenzDbMock(), clock, new ConfigServerMock(new ZoneRegistryMock()), + this(new AthenzDbMock(), clock, new ZoneRegistryMock(), curatorDb, rotationsConfig, - new MemoryNameService(), new ArtifactRepositoryMock(), new ApplicationStoreMock(), new MockBuildService(), - metricsService, new RoutingGeneratorMock(), new MockContactRetriever(), new MemoryGlobalRoutingService()); + new ArtifactRepositoryMock(), new ApplicationStoreMock(), new MockBuildService(), + metricsService, new RoutingGeneratorMock(), new MockContactRetriever(), + new ServiceRegistryMock()); } public ControllerTester(ManualClock clock) { @@ -119,18 +118,18 @@ public final class ControllerTester { } private ControllerTester(AthenzDbMock athenzDb, ManualClock clock, - ConfigServerMock configServer, ZoneRegistryMock zoneRegistry, + ZoneRegistryMock zoneRegistry, CuratorDb curator, RotationsConfig rotationsConfig, - MemoryNameService nameService, ArtifactRepositoryMock artifactRepository, + ArtifactRepositoryMock artifactRepository, ApplicationStoreMock appStoreMock, MockBuildService buildService, MetricsServiceMock metricsService, RoutingGeneratorMock routingGenerator, - MockContactRetriever contactRetriever, MemoryGlobalRoutingService globalRoutingService) { + MockContactRetriever contactRetriever, + ServiceRegistryMock serviceRegistry) { this.athenzDb = athenzDb; this.clock = clock; - this.configServer = configServer; this.zoneRegistry = zoneRegistry; + this.serviceRegistry = serviceRegistry; this.curator = curator; - this.nameService = nameService; this.rotationsConfig = rotationsConfig; this.artifactRepository = artifactRepository; this.applicationStore = appStoreMock; @@ -138,10 +137,9 @@ public final class ControllerTester { this.metricsService = metricsService; this.routingGenerator = routingGenerator; this.contactRetriever = contactRetriever; - this.globalRoutingService = globalRoutingService; - this.controller = createController(curator, rotationsConfig, configServer, clock, zoneRegistry, + this.controller = createController(curator, rotationsConfig, clock, zoneRegistry, athenzDb, artifactRepository, appStoreMock, buildService, - metricsService, routingGenerator, globalRoutingService); + metricsService, routingGenerator, serviceRegistry); // Make root logger use time from manual clock configureDefaultLogHandler(handler -> handler.setFilter( @@ -171,11 +169,13 @@ public final class ControllerTester { public AthenzDbMock athenzDb() { return athenzDb; } - public MemoryNameService nameService() { return nameService; } + public MemoryNameService nameService() { return serviceRegistry.nameServiceMock(); } public ZoneRegistryMock zoneRegistry() { return zoneRegistry; } - public ConfigServerMock configServer() { return configServer; } + public ConfigServerMock configServer() { return serviceRegistry.configServerMock(); } + + public ServiceRegistryMock serviceRegistry() { return serviceRegistry; } public ArtifactRepositoryMock artifactRepository() { return artifactRepository; } @@ -191,19 +191,15 @@ public final class ControllerTester { return contactRetriever; } - public MemoryGlobalRoutingService globalRoutingService() { - return globalRoutingService; - } - public Optional<Record> findCname(String name) { - return nameService.findRecords(Record.Type.CNAME, RecordName.from(name)).stream().findFirst(); + return serviceRegistry.nameService().findRecords(Record.Type.CNAME, RecordName.from(name)).stream().findFirst(); } /** Create a new controller instance. Useful to verify that controller state is rebuilt from persistence */ public final void createNewController() { - controller = createController(curator, rotationsConfig, configServer, clock, zoneRegistry, athenzDb, + controller = createController(curator, rotationsConfig, clock, zoneRegistry, athenzDb, artifactRepository, applicationStore, buildService, metricsService, - routingGenerator, globalRoutingService); + routingGenerator, serviceRegistry); } /** Creates the given tenant and application and deploys it */ @@ -332,17 +328,16 @@ public final class ControllerTester { } private static Controller createController(CuratorDb curator, RotationsConfig rotationsConfig, - ConfigServerMock configServer, ManualClock clock, + ManualClock clock, ZoneRegistryMock zoneRegistryMock, AthenzDbMock athensDb, ArtifactRepository artifactRepository, ApplicationStore applicationStore, BuildService buildService, MetricsServiceMock metricsService, RoutingGenerator routingGenerator, - MemoryGlobalRoutingService globalRoutingService) { + ServiceRegistryMock serviceRegistry) { Controller controller = new Controller(curator, rotationsConfig, zoneRegistryMock, - configServer, metricsService, routingGenerator, clock, @@ -358,7 +353,7 @@ public final class ControllerTester { new MockMavenRepository(), new ApplicationCertificateMock(), new MockMeteringClient(), - globalRoutingService); + serviceRegistry); // Calculate initial versions controller.updateVersionStatus(VersionStatus.compute(controller)); return controller; diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java index 46422188a01..05fb9927724 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.deployment; import com.yahoo.component.Version; @@ -76,7 +76,6 @@ public class DeploymentTester { this.readyJobTrigger = new ReadyJobsTrigger(tester.controller(), maintenanceInterval, jobControl); this.nameServiceDispatcher = new NameServiceDispatcher(tester.controller(), Duration.ofHours(12), new JobControl(tester.controller().curator()), - controllerTester().nameService(), Integer.MAX_VALUE); } @@ -98,7 +97,7 @@ public class DeploymentTester { public ControllerTester controllerTester() { return tester; } - public ConfigServerMock configServer() { return tester.configServer(); } + public ConfigServerMock configServer() { return tester.serviceRegistry().configServerMock(); } public ArtifactRepositoryMock artifactRepository() { return tester.artifactRepository(); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java new file mode 100644 index 00000000000..f41d7760698 --- /dev/null +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java @@ -0,0 +1,54 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.hosted.controller.integration; + +import com.yahoo.component.AbstractComponent; +import com.yahoo.vespa.hosted.controller.api.integration.ServiceRegistry; +import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; +import com.yahoo.vespa.hosted.controller.api.integration.dns.MemoryNameService; +import com.yahoo.vespa.hosted.controller.api.integration.dns.NameService; +import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService; +import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService; + +/** + * A mock implementation of a {@link ServiceRegistry} for testing purposes. + * + * @author mpolden + */ +public class ServiceRegistryMock extends AbstractComponent implements ServiceRegistry { + + private final ZoneRegistryMock zoneRegistryMock = new ZoneRegistryMock(); + private final ConfigServerMock configServerMock = new ConfigServerMock(zoneRegistryMock); + private final MemoryNameService memoryNameService = new MemoryNameService(); + private final MemoryGlobalRoutingService memoryGlobalRoutingService = new MemoryGlobalRoutingService(); + + @Override + public ConfigServer configServer() { + return configServerMock; + } + + @Override + public GlobalRoutingService globalRoutingService() { + return memoryGlobalRoutingService; + } + + @Override + public NameService nameService() { + return memoryNameService; + } + + public ZoneRegistryMock zoneRegistryMock() { + return zoneRegistryMock; + } + + public ConfigServerMock configServerMock() { + return configServerMock; + } + + public MemoryNameService nameServiceMock() { + return memoryNameService; + } + + public MemoryGlobalRoutingService globalRoutingServiceMock() { + return memoryGlobalRoutingService; + } +} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java index 903b1378438..f0b12cb48b6 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java @@ -25,7 +25,7 @@ public class RotationStatusUpdaterTest { @Test public void updates_rotation_status() { var tester = new DeploymentTester(); - var globalRotationService = tester.controllerTester().globalRoutingService(); + var globalRotationService = tester.controllerTester().serviceRegistry().globalRoutingServiceMock(); var updater = new RotationStatusUpdater(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator())); var application = tester.createApplication("app1", "tenant1", 1, 1L); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java index d920b5d5769..7f0b07e4c93 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ContainerTester.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.restapi; import com.yahoo.application.container.JDisc; @@ -13,6 +13,7 @@ import com.yahoo.jdisc.http.filter.SecurityRequestFilterChain; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.application.SystemApplication; import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; +import com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock; import com.yahoo.vespa.hosted.controller.versions.ControllerVersion; import com.yahoo.vespa.hosted.controller.versions.VersionStatus; import org.junit.ComparisonFailure; @@ -52,7 +53,11 @@ public class ContainerTester { } public ConfigServerMock configServer() { - return (ConfigServerMock) container.components().getComponent(ConfigServerMock.class.getName()); + return serviceRegistry().configServerMock(); + } + + public ServiceRegistryMock serviceRegistry() { + return (ServiceRegistryMock) container.components().getComponent(ServiceRegistryMock.class.getName()); } public void computeVersionStatus() { diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java index 7be0be9c80d..d697e9051b8 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.restapi; import com.yahoo.application.Networking; @@ -64,9 +64,7 @@ public class ControllerContainerTest { " <component id='com.yahoo.vespa.curator.mock.MockCurator'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.persistence.MockCuratorDb'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.athenz.mock.AthenzClientFactoryMock'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.dns.MemoryNameService'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.entity.MemoryEntityService'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.LoggingDeploymentIssues'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.restapi.cost.NoopCostReportConsumer'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.DummyOwnershipIssues'/>\n" + @@ -76,8 +74,8 @@ public class ControllerContainerTest { " <component id='com.yahoo.vespa.hosted.controller.api.integration.aws.MockAwsEventFetcher' />\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.organization.MockBilling'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.integration.ConfigServerMock'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock'/>\n" + + " <component id='com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.Controller'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService'/>\n" + " <component id='com.yahoo.vespa.hosted.controller.integration.ConfigServerProxyMock'/>\n" + diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java index 07c68d738c0..9db289ae054 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.restapi.application; import ai.vespa.hosted.api.MultiPartStreamer; @@ -39,7 +39,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.organization.User; import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringInfo; import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceAllocation; import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceSnapshot; -import com.yahoo.vespa.hosted.controller.api.integration.routing.MemoryGlobalRoutingService; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMeteringClient; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.Change; @@ -59,6 +58,7 @@ import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder; import com.yahoo.vespa.hosted.controller.deployment.BuildJob; import com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger; import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; +import com.yahoo.vespa.hosted.controller.integration.ServiceRegistryMock; import com.yahoo.vespa.hosted.controller.maintenance.JobControl; import com.yahoo.vespa.hosted.controller.maintenance.RotationStatusUpdater; import com.yahoo.vespa.hosted.controller.restapi.ContainerControllerTester; @@ -1039,7 +1039,7 @@ public class ApplicationApiTest extends ControllerContainerTest { "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Could not create 'tenant1.application1.instance1': Application already exists\"}", 400); - ConfigServerMock configServer = (ConfigServerMock) container.components().getComponent(ConfigServerMock.class.getName()); + ConfigServerMock configServer = serviceRegistry().configServerMock(); configServer.throwOnNextPrepare(new ConfigServerException(new URI("server-url"), "Failed to prepare application", ConfigServerException.ErrorCode.INVALID_APPLICATION_PACKAGE, null)); // POST (deploy) an application with an invalid application package @@ -1723,8 +1723,8 @@ public class ApplicationApiTest extends ControllerContainerTest { } } - private MemoryGlobalRoutingService globalRoutingService() { - return (MemoryGlobalRoutingService) tester.container().components().getComponent(MemoryGlobalRoutingService.class.getName()); + private ServiceRegistryMock serviceRegistry() { + return (ServiceRegistryMock) tester.container().components().getComponent(ServiceRegistryMock.class.getName()); } private MockContactRetriever contactRetriever() { @@ -1732,14 +1732,14 @@ public class ApplicationApiTest extends ControllerContainerTest { } private void setZoneInRotation(String rotationName, ZoneId zone) { - globalRoutingService().setStatus(rotationName, zone, com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus.IN); + serviceRegistry().globalRoutingServiceMock().setStatus(rotationName, zone, com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus.IN); new RotationStatusUpdater(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator())).run(); } private RotationStatus rotationStatus(Application application) { return controllerTester.controller().applications().rotationRepository().getRotation(application) .map(rotation -> { - var rotationStatus = controllerTester.controller().globalRoutingService().getHealthStatus(rotation.name()); + var rotationStatus = controllerTester.controller().serviceRegistry().globalRoutingService().getHealthStatus(rotation.name()); var statusMap = new LinkedHashMap<ZoneId, RotationState>(); rotationStatus.forEach((zone, status) -> statusMap.put(zone, RotationState.in)); return RotationStatus.from(Map.of(rotation.id(), statusMap)); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java index 3ef6dfc403d..ca7545e350f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/os/OsApiTest.java @@ -1,4 +1,4 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.restapi.os; import com.yahoo.application.container.handler.Request; @@ -11,7 +11,6 @@ import com.yahoo.vespa.athenz.api.AthenzIdentity; import com.yahoo.vespa.athenz.api.AthenzUser; import com.yahoo.vespa.hosted.controller.api.integration.configserver.Node; import com.yahoo.vespa.hosted.controller.application.SystemApplication; -import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock; import com.yahoo.vespa.hosted.controller.integration.NodeRepositoryMock; import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; import com.yahoo.vespa.hosted.controller.integration.ZoneRegistryMock; @@ -164,8 +163,7 @@ public class OsApiTest extends ControllerContainerTest { } private NodeRepositoryMock nodeRepository() { - return ((ConfigServerMock) tester.containerTester().container().components() - .getComponent(ConfigServerMock.class.getName())).nodeRepository(); + return tester.containerTester().serviceRegistry().configServerMock().nodeRepository(); } private void assertResponse(Request request, @Language("JSON") String body, int statusCode) { |