diff options
author | Martin Polden <mpolden@mpolden.no> | 2019-09-05 13:09:47 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2019-09-09 10:34:17 +0200 |
commit | e907b0f160171e29df80828b51f1e751471849a9 (patch) | |
tree | 1bf3d80bdffda751214c5e7586f9c3f200ec2f86 | |
parent | 938d615d5b00968311be6eca034ccc35b7a92fa3 (diff) |
Move AwsEventFetcher to ServiceRegistry
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java | 3 | ||||
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsEventFetcher.java | 3 | ||||
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventReporter.java (renamed from controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/AwsEventReporterMaintainer.java) | 11 | ||||
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java | 10 | ||||
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/integration/ServiceRegistryMock.java | 8 | ||||
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/ControllerContainerTest.java | 1 | ||||
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json | 4 |
7 files changed, 25 insertions, 15 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 index 49cfd770197..05cfc037d1e 100644 --- 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 @@ -1,6 +1,7 @@ // 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.aws.AwsEventFetcher; 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.dns.NameService; @@ -53,4 +54,6 @@ public interface ServiceRegistry { Billing billingService(); + AwsEventFetcher eventFetcherService(); + } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsEventFetcher.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsEventFetcher.java index 8e7a261100a..606d7add8b0 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsEventFetcher.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/aws/AwsEventFetcher.java @@ -4,6 +4,9 @@ import com.yahoo.vespa.hosted.controller.api.integration.organization.Issue; import java.util.List; +/** + * @author freva + */ public interface AwsEventFetcher { List<CloudEvent> getEvents(String awsRegionName); diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/AwsEventReporterMaintainer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventReporter.java index 9a8adadd56e..9141fe30f14 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/AwsEventReporterMaintainer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CloudEventReporter.java @@ -20,19 +20,18 @@ import java.util.stream.Collectors; * * @author mgimle */ -public class AwsEventReporterMaintainer extends Maintainer { +public class CloudEventReporter extends Maintainer { - private static final Logger log = Logger.getLogger(AwsEventReporterMaintainer.class.getName()); + private static final Logger log = Logger.getLogger(CloudEventReporter.class.getName()); private final IssueHandler issueHandler; private final AwsEventFetcher eventFetcher; private final Set<String> awsRegions; - AwsEventReporterMaintainer(Controller controller, Duration interval, JobControl jobControl, - IssueHandler issueHandler, AwsEventFetcher eventFetcher) { + CloudEventReporter(Controller controller, Duration interval, JobControl jobControl) { super(controller, interval, jobControl); - this.issueHandler = issueHandler; - this.eventFetcher = eventFetcher; + this.issueHandler = controller.serviceRegistry().issueHandler(); + this.eventFetcher = controller.serviceRegistry().eventFetcherService(); this.awsRegions = controller.zoneRegistry().zones() .ofCloud(CloudName.from("aws")) .reachable() 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 a90554bcb62..bf58b831566 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 @@ -5,7 +5,6 @@ import com.yahoo.component.AbstractComponent; 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.maintenance.config.MaintainerConfig; import com.yahoo.vespa.hosted.controller.persistence.CuratorDb; @@ -44,7 +43,7 @@ public class ControllerMaintenance extends AbstractComponent { private final ResourceMeterMaintainer resourceMeterMaintainer; private final NameServiceDispatcher nameServiceDispatcher; private final BillingMaintainer billingMaintainer; - private final AwsEventReporterMaintainer awsEventReporterMaintainer; + private final CloudEventReporter cloudEventReporter; private final RotationStatusUpdater rotationStatusUpdater; @SuppressWarnings("unused") // instantiated by Dependency Injection @@ -52,8 +51,7 @@ public class ControllerMaintenance extends AbstractComponent { Controller controller, CuratorDb curator, JobControl jobControl, - Metric metric, - AwsEventFetcher awsEventFetcher) { + Metric metric) { Duration maintenanceInterval = Duration.ofMinutes(maintainerConfig.intervalMinutes()); this.jobControl = jobControl; deploymentExpirer = new DeploymentExpirer(controller, maintenanceInterval, jobControl); @@ -75,7 +73,7 @@ public class ControllerMaintenance extends AbstractComponent { costReportMaintainer = new CostReportMaintainer(controller, Duration.ofHours(2), jobControl, controller.serviceRegistry().costReportConsumer()); resourceMeterMaintainer = new ResourceMeterMaintainer(controller, Duration.ofMinutes(30), jobControl, metric, controller.serviceRegistry().meteringService()); billingMaintainer = new BillingMaintainer(controller, Duration.ofDays(3), jobControl); - awsEventReporterMaintainer = new AwsEventReporterMaintainer(controller, Duration.ofDays(1), jobControl, controller.serviceRegistry().issueHandler(), awsEventFetcher); + cloudEventReporter = new CloudEventReporter(controller, Duration.ofDays(1), jobControl); rotationStatusUpdater = new RotationStatusUpdater(controller, maintenanceInterval, jobControl); } @@ -105,7 +103,7 @@ public class ControllerMaintenance extends AbstractComponent { resourceMeterMaintainer.deconstruct(); nameServiceDispatcher.deconstruct(); billingMaintainer.deconstruct(); - awsEventReporterMaintainer.deconstruct(); + cloudEventReporter.deconstruct(); rotationStatusUpdater.deconstruct(); } 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 aacc6dbd7b0..07ba5555c7c 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 @@ -3,6 +3,8 @@ 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.aws.AwsEventFetcher; +import com.yahoo.vespa.hosted.controller.api.integration.aws.MockAwsEventFetcher; import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificateMock; import com.yahoo.vespa.hosted.controller.api.integration.certificates.ApplicationCertificateProvider; import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer; @@ -52,6 +54,7 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg private final MemoryEntityService memoryEntityService = new MemoryEntityService(); private final CostReportConsumerMock costReportConsumerMock = new CostReportConsumerMock(); private final MockBilling mockBilling = new MockBilling(); + private final MockAwsEventFetcher mockAwsEventFetcher = new MockAwsEventFetcher(); @Override public ConfigServer configServer() { @@ -119,6 +122,11 @@ public class ServiceRegistryMock extends AbstractComponent implements ServiceReg } @Override + public AwsEventFetcher eventFetcherService() { + return mockAwsEventFetcher; + } + + @Override public NameService nameService() { return memoryNameService; } 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 549e3dc8a5e..108242124bf 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 @@ -65,7 +65,6 @@ public class ControllerContainerTest { " <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.stubs.MockRunDataStore'/>\n" + - " <component id='com.yahoo.vespa.hosted.controller.api.integration.aws.MockAwsEventFetcher' />\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" + diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json index 4dfd6dcfaad..28d2980181f 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json @@ -4,10 +4,10 @@ "name": "ApplicationOwnershipConfirmer" }, { - "name": "AwsEventReporterMaintainer" + "name": "BillingMaintainer" }, { - "name": "BillingMaintainer" + "name": "CloudEventReporter" }, { "name": "ClusterInfoMaintainer" |