summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@yahooinc.com>2022-05-16 14:13:39 +0200
committerØyvind Grønnesby <oyving@yahooinc.com>2022-05-16 14:13:39 +0200
commit2cec988e00a7c828165262d8eb70271812e2d378 (patch)
tree4cdeb480bff9f77efa0485fce922bb22bbb2966a /controller-api
parentfc458207c3d957a79c909fe5daceaf0efcbbadad (diff)
Remove MeteringClient
MeteringClient was just a thin shim around ResourceDatabaseClient now. Use RDC directly instead.
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java3
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java11
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMeteringClient.java53
3 files changed, 5 insertions, 62 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 52f687e5708..33a87e82ec9 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
@@ -29,7 +29,6 @@ import com.yahoo.vespa.hosted.controller.api.integration.organization.Mailer;
import com.yahoo.vespa.hosted.controller.api.integration.organization.OwnershipIssues;
import com.yahoo.vespa.hosted.controller.api.integration.organization.SystemMonitor;
import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportConsumer;
-import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient;
import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceDatabaseClient;
import com.yahoo.vespa.hosted.controller.api.integration.secrets.TenantSecretService;
import com.yahoo.vespa.hosted.controller.api.integration.user.RoleMaintainer;
@@ -63,8 +62,6 @@ public interface ServiceRegistry {
EndpointCertificateValidator endpointCertificateValidator();
- MeteringClient meteringService();
-
ContactRetriever contactRetriever();
IssueHandler issueHandler();
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java
index c680990e240..e9bfc4fe78c 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/ResourceDatabaseClientMock.java
@@ -1,7 +1,6 @@
// 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.resource;
-import com.yahoo.config.provision.ApplicationName;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.hosted.controller.api.integration.billing.Plan;
import com.yahoo.vespa.hosted.controller.api.integration.billing.PlanRegistry;
@@ -9,9 +8,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.billing.PlanRegistry;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.Instant;
-import java.time.LocalDate;
import java.time.YearMonth;
-import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -104,7 +101,7 @@ public class ResourceDatabaseClientMock implements ResourceDatabaseClient {
public List<ResourceUsage> getResourceSnapshotsForPeriod(TenantName tenantName, long start, long end) {
var tenantPlan = planMap.getOrDefault(tenantName, planRegistry.defaultPlan());
- var snapshotsPerDeployment = resourceSnapshots.stream()
+ return resourceSnapshots.stream()
.filter(snapshot -> snapshot.getTimestamp().isAfter(Instant.ofEpochMilli(start)))
.filter(snapshot -> snapshot.getTimestamp().isBefore(Instant.ofEpochMilli(end)))
.filter(snapshot -> snapshot.getApplicationId().tenant().equals(tenantName))
@@ -117,8 +114,6 @@ public class ResourceDatabaseClientMock implements ResourceDatabaseClient {
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
-
- return snapshotsPerDeployment;
}
@Override
@@ -133,4 +128,8 @@ public class ResourceDatabaseClientMock implements ResourceDatabaseClient {
public boolean hasRefreshedMaterializedView() {
return hasRefreshedMaterializedView;
}
+
+ public List<ResourceSnapshot> resourceSnapshots() {
+ return resourceSnapshots;
+ }
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMeteringClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMeteringClient.java
deleted file mode 100644
index ca094f98607..00000000000
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMeteringClient.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.api.integration.stubs;
-
-import com.yahoo.config.provision.TenantName;
-import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringData;
-import com.yahoo.vespa.hosted.controller.api.integration.resource.ResourceSnapshot;
-import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient;
-
-import java.time.YearMonth;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-/**
- * @author olaa
- */
-public class MockMeteringClient implements MeteringClient {
-
- private Collection<ResourceSnapshot> resources = new ArrayList<>();
- private Optional<MeteringData> meteringData;
- private boolean isRefreshed = false;
-
- @Override
- public void consume(Collection<ResourceSnapshot> resources){
- this.resources = resources;
- }
-
- @Override
- public List<ResourceSnapshot> getSnapshotHistoryForTenant(TenantName tenantName, YearMonth yearMonth) {
- return new ArrayList<>(resources);
- }
-
- @Override
- public void refresh() {
- isRefreshed = true;
- }
-
- public Collection<ResourceSnapshot> consumedResources() {
- return this.resources;
- }
-
- public void setMeteringData(MeteringData meteringData) {
- this.meteringData = Optional.of(meteringData);
- this.resources = meteringData.getSnapshotHistory().entrySet().stream().map(Map.Entry::getValue).flatMap(List::stream).collect(Collectors.toList());
- }
-
- public boolean isRefreshed() {
- return isRefreshed;
- }
-}