summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2019-09-02 14:52:58 +0200
committerMartin Polden <mpolden@mpolden.no>2019-09-04 09:15:44 +0200
commit3f8ab20f86b3c8348e55c01400f940241698589a (patch)
tree6c2a3be50bbf79ea395c124af17504e1d9168495 /controller-server
parent167b02afe8a20dfa90ccf2634a7f4fb1d7270011 (diff)
Move RoutingGenerator to ServiceRegistry
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java7
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/Controller.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTester.java28
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java12
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java1
8 files changed, 34 insertions, 30 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
index f40db70669f..c7a9a1d539c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java
@@ -130,14 +130,13 @@ public class ApplicationController {
ApplicationController(Controller controller, CuratorDb curator,
AccessControl accessControl, RotationsConfig rotationsConfig,
- ConfigServer configServer,
ArtifactRepository artifactRepository, ApplicationStore applicationStore,
- RoutingGenerator routingGenerator, BuildService buildService, Clock clock) {
+ BuildService buildService, Clock clock) {
this.controller = controller;
this.curator = curator;
this.accessControl = accessControl;
- this.configServer = configServer;
- this.routingGenerator = routingGenerator;
+ this.configServer = controller.serviceRegistry().configServer();
+ this.routingGenerator = controller.serviceRegistry().routingGenerator();
this.routingPolicies = new RoutingPolicies(controller);
this.clock = clock;
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 707da83ac83..6dfcaa924a9 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
@@ -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.RoutingGenerator;
import com.yahoo.vespa.hosted.controller.api.integration.user.Roles;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry;
import com.yahoo.vespa.hosted.controller.api.role.ApplicationRole;
@@ -94,14 +93,13 @@ public class Controller extends AbstractComponent {
@Inject
public Controller(CuratorDb curator, RotationsConfig rotationsConfig,
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, ServiceRegistry serviceRegistry) {
this(curator, rotationsConfig, zoneRegistry,
- metricsService, routingGenerator,
+ metricsService,
Clock.systemUTC(), accessControl, artifactRepository, applicationStore, testerCloud,
buildService, runDataStore, com.yahoo.net.HostName::getLocalhost, mailer, flagSource,
mavenRepository, applicationCertificateProvider, meteringClient, serviceRegistry);
@@ -110,7 +108,7 @@ public class Controller extends AbstractComponent {
public Controller(CuratorDb curator, RotationsConfig rotationsConfig,
ZoneRegistry zoneRegistry,
MetricsService metricsService,
- RoutingGenerator routingGenerator, Clock clock,
+ Clock clock,
AccessControl accessControl,
ArtifactRepository artifactRepository, ApplicationStore applicationStore, TesterCloud testerCloud,
BuildService buildService, RunDataStore runDataStore, Supplier<String> hostnameSupplier,
@@ -134,10 +132,8 @@ public class Controller extends AbstractComponent {
jobController = new JobController(this, runDataStore, Objects.requireNonNull(testerCloud));
applicationController = new ApplicationController(this, curator, accessControl,
Objects.requireNonNull(rotationsConfig, "RotationsConfig cannot be null"),
- serviceRegistry.configServer(),
Objects.requireNonNull(artifactRepository, "ArtifactRepository cannot be null"),
Objects.requireNonNull(applicationStore, "ApplicationStore cannot be null"),
- Objects.requireNonNull(routingGenerator, "RoutingGenerator cannot be null"),
Objects.requireNonNull(buildService, "BuildService cannot be null"),
clock
);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
index 210b94737b0..19d2ff5a544 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java
@@ -236,7 +236,7 @@ public class ControllerTest {
ZoneId zone = ZoneId.from(Environment.defaultEnvironment(), RegionName.defaultName());
ApplicationId app = ApplicationId.from("tenant", "app1", "default");
DeploymentId deployment = new DeploymentId(app, zone);
- tester.routingGenerator().putEndpoints(deployment, List.of(
+ tester.serviceRegistry().routingGeneratorMock().putEndpoints(deployment, List.of(
new RoutingEndpoint("http://old-endpoint.vespa.yahooapis.com:4080", "host1", false, "upstream2"),
new RoutingEndpoint("http://qrs-endpoint.vespa.yahooapis.com:4080", "host1", false, "upstream1"),
new RoutingEndpoint("http://feeding-endpoint.vespa.yahooapis.com:4080", "host2", false, "upstream3"),
@@ -265,7 +265,7 @@ public class ControllerTest {
assertEquals("unit-test", findStatusByUpstream.apply("upstream1").get().getReason());
// Deployment without a global endpoint
- tester.routingGenerator().putEndpoints(deployment, List.of(
+ tester.serviceRegistry().routingGeneratorMock().putEndpoints(deployment, List.of(
new RoutingEndpoint("http://old-endpoint.vespa.yahooapis.com:4080", "host1", false, "upstream2"),
new RoutingEndpoint("http://qrs-endpoint.vespa.yahooapis.com:4080", "host1", false, "upstream1"),
new RoutingEndpoint("http://feeding-endpoint.vespa.yahooapis.com:4080", "host2", false, "upstream3")
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 0cabd2ce63c..26d153b0b19 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
@@ -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.RoutingGenerator;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockBuildService;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMailer;
import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMavenRepository;
@@ -43,7 +42,6 @@ import com.yahoo.vespa.hosted.controller.integration.ApplicationStoreMock;
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;
@@ -87,17 +85,22 @@ public final class ControllerTester {
private final ApplicationStoreMock applicationStore;
private final MockBuildService buildService;
private final MetricsServiceMock metricsService;
- private final RoutingGeneratorMock routingGenerator;
private final MockContactRetriever contactRetriever;
private Controller controller;
public ControllerTester(ManualClock clock, RotationsConfig rotationsConfig, MockCuratorDb curatorDb,
MetricsServiceMock metricsService) {
- this(new AthenzDbMock(), clock,
- new ZoneRegistryMock(), curatorDb, rotationsConfig,
- new ArtifactRepositoryMock(), new ApplicationStoreMock(), new MockBuildService(),
- metricsService, new RoutingGeneratorMock(), new MockContactRetriever(),
+ this(new AthenzDbMock(),
+ clock,
+ new ZoneRegistryMock(),
+ curatorDb,
+ rotationsConfig,
+ new ArtifactRepositoryMock(),
+ new ApplicationStoreMock(),
+ new MockBuildService(),
+ metricsService,
+ new MockContactRetriever(),
new ServiceRegistryMock());
}
@@ -122,7 +125,7 @@ public final class ControllerTester {
CuratorDb curator, RotationsConfig rotationsConfig,
ArtifactRepositoryMock artifactRepository,
ApplicationStoreMock appStoreMock, MockBuildService buildService,
- MetricsServiceMock metricsService, RoutingGeneratorMock routingGenerator,
+ MetricsServiceMock metricsService,
MockContactRetriever contactRetriever,
ServiceRegistryMock serviceRegistry) {
this.athenzDb = athenzDb;
@@ -135,11 +138,10 @@ public final class ControllerTester {
this.applicationStore = appStoreMock;
this.buildService = buildService;
this.metricsService = metricsService;
- this.routingGenerator = routingGenerator;
this.contactRetriever = contactRetriever;
this.controller = createController(curator, rotationsConfig, clock, zoneRegistry,
athenzDb, artifactRepository, appStoreMock, buildService,
- metricsService, routingGenerator, serviceRegistry);
+ metricsService, serviceRegistry);
// Make root logger use time from manual clock
configureDefaultLogHandler(handler -> handler.setFilter(
@@ -185,8 +187,6 @@ public final class ControllerTester {
public MetricsServiceMock metricsService() { return metricsService; }
- public RoutingGeneratorMock routingGenerator() { return routingGenerator; }
-
public MockContactRetriever contactRetriever() {
return contactRetriever;
}
@@ -199,7 +199,7 @@ public final class ControllerTester {
public final void createNewController() {
controller = createController(curator, rotationsConfig, clock, zoneRegistry, athenzDb,
artifactRepository, applicationStore, buildService, metricsService,
- routingGenerator, serviceRegistry);
+ serviceRegistry);
}
/** Creates the given tenant and application and deploys it */
@@ -333,13 +333,11 @@ public final class ControllerTester {
AthenzDbMock athensDb,
ArtifactRepository artifactRepository, ApplicationStore applicationStore,
BuildService buildService, MetricsServiceMock metricsService,
- RoutingGenerator routingGenerator,
ServiceRegistryMock serviceRegistry) {
Controller controller = new Controller(curator,
rotationsConfig,
zoneRegistryMock,
metricsService,
- routingGenerator,
clock,
new AthenzFacade(new AthenzClientFactoryMock(athensDb)),
artifactRepository,
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java
index 46e991a135a..fdb797a6bcd 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalDeploymentTester.java
@@ -78,7 +78,7 @@ public class InternalDeploymentTester {
"default",
1);
jobs = tester.controller().jobController();
- routing = tester.controllerTester().routingGenerator();
+ routing = tester.controllerTester().serviceRegistry().routingGeneratorMock();
cloud = (MockTesterCloud) tester.controller().jobController().cloud();
runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
JobRunnerTest.inThreadExecutor(), new InternalStepRunner(tester.controller()));
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
index f41d7760698..8c50d7fed6d 100644
--- 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
@@ -8,6 +8,7 @@ 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;
+import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator;
/**
* A mock implementation of a {@link ServiceRegistry} for testing purposes.
@@ -20,6 +21,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
private final ConfigServerMock configServerMock = new ConfigServerMock(zoneRegistryMock);
private final MemoryNameService memoryNameService = new MemoryNameService();
private final MemoryGlobalRoutingService memoryGlobalRoutingService = new MemoryGlobalRoutingService();
+ private final RoutingGeneratorMock routingGeneratorMock = new RoutingGeneratorMock();
@Override
public ConfigServer configServer() {
@@ -32,6 +34,11 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
}
@Override
+ public RoutingGenerator routingGenerator() {
+ return routingGeneratorMock;
+ }
+
+ @Override
public NameService nameService() {
return memoryNameService;
}
@@ -51,4 +58,9 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg
public MemoryGlobalRoutingService globalRoutingServiceMock() {
return memoryGlobalRoutingService;
}
+
+ public RoutingGeneratorMock routingGeneratorMock() {
+ return routingGeneratorMock;
+ }
+
}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java
index 9be4eb5f5b4..0dee5fcb78c 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RoutingPoliciesTest.java
@@ -228,7 +228,7 @@ public class RoutingPoliciesTest {
public void cluster_endpoints_resolve_from_policies() {
provisionLoadBalancers(3, app1.id(), zone1);
tester.deployCompletely(app1, applicationPackage);
- tester.controllerTester().routingGenerator().putEndpoints(new DeploymentId(app1.id(), zone1), Collections.emptyList());
+ tester.controllerTester().serviceRegistry().routingGeneratorMock().putEndpoints(new DeploymentId(app1.id(), zone1), Collections.emptyList());
assertEquals(Map.of(ClusterSpec.Id.from("c0"),
URI.create("https://c0.app1.tenant1.us-west-1.vespa.oath.cloud/"),
ClusterSpec.Id.from("c1"),
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 d697e9051b8..4c05d052e93 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
@@ -86,7 +86,6 @@ public class ControllerContainerTest {
" </config>" +
" </component>" +
" <component id='com.yahoo.vespa.hosted.controller.maintenance.JobControl'/>\n" +
- " <component id='com.yahoo.vespa.hosted.controller.integration.RoutingGeneratorMock'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.integration.ArtifactRepositoryMock'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.integration.ApplicationStoreMock'/>\n" +
" <component id='com.yahoo.vespa.hosted.controller.api.integration.stubs.MockTesterCloud'/>\n" +