summaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@verizonmedia.com>2019-10-17 10:41:15 +0200
committerOla Aunrønning <olaa@verizonmedia.com>2019-10-17 10:41:15 +0200
commit7f0b02ec8e4e6cad99560073963338ddf6746e90 (patch)
treef7ad351f85d864d14e3f92f6498159dcfa733001 /controller-api
parent0f378f6aeae4ab1afef700ee49257ff2074e4d14 (diff)
Added TenantCost
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/CostInfo.java67
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MeteringClient.java6
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MockTenantCost.java37
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/TenantCost.java19
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/stubs/MockMeteringClient.java4
6 files changed, 133 insertions, 3 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 f545cb8ff47..dec5d9264a7 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
@@ -17,6 +17,7 @@ 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.resource.CostReportConsumer;
import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient;
+import com.yahoo.vespa.hosted.controller.api.integration.resource.TenantCost;
import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService;
import com.yahoo.vespa.hosted.controller.api.integration.routing.RoutingGenerator;
@@ -70,4 +71,6 @@ public interface ServiceRegistry {
// TODO: No longer used. Remove this once untangled from test code
BuildService buildService();
+ TenantCost tenantCost();
+
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/CostInfo.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/CostInfo.java
new file mode 100644
index 00000000000..ed63b1608ca
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/CostInfo.java
@@ -0,0 +1,67 @@
+// 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.ApplicationId;
+import com.yahoo.config.provision.zone.ZoneId;
+
+/**
+ * @author olaa
+ */
+public class CostInfo {
+
+ private final ApplicationId applicationId;
+ private final ZoneId zoneId;
+ private final double cpuHours;
+ private final double memoryHours;
+ private final double diskHours;
+ private final int cpuCost;
+ private final int memoryCost;
+ private final int diskCost;
+
+
+ public CostInfo(ApplicationId applicationId, ZoneId zoneId,
+ double cpuHours, double memoryHours, double diskHours,
+ int cpuCost, int memoryCost, int diskCost) {
+ this.applicationId = applicationId;
+ this.zoneId = zoneId;
+ this.cpuHours = cpuHours;
+ this.memoryHours = memoryHours;
+ this.diskHours = diskHours;
+ this.cpuCost = cpuCost;
+ this.memoryCost = memoryCost;
+ this.diskCost = diskCost;
+ }
+
+ public ApplicationId getApplicationId() {
+ return applicationId;
+ }
+
+ public ZoneId getZoneId() {
+ return zoneId;
+ }
+
+ public double getCpuHours() {
+ return cpuHours;
+ }
+
+ public double getMemoryHours() {
+ return memoryHours;
+ }
+
+ public double getDiskHours() {
+ return diskHours;
+ }
+
+ public int getCpuCost() {
+ return cpuCost;
+ }
+
+ public int getMemoryCost() {
+ return memoryCost;
+ }
+
+ public int getDiskCost() {
+ return diskCost;
+ }
+
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MeteringClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MeteringClient.java
index 632dbaad419..3e06b24c6be 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MeteringClient.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MeteringClient.java
@@ -1,8 +1,10 @@
// 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 java.util.Collection;
-import java.util.List;
/**
* Consumes and retrieves snapshots of resources allocated per application.
@@ -13,6 +15,6 @@ public interface MeteringClient {
void consume(Collection<ResourceSnapshot> resources);
- MeteringInfo getResourceSnapshots(String tenantName, String applicationName);
+ MeteringInfo getResourceSnapshots(TenantName tenantName, ApplicationName applicationName);
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MockTenantCost.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MockTenantCost.java
new file mode 100644
index 00000000000..03ba44e04c7
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/MockTenantCost.java
@@ -0,0 +1,37 @@
+// 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.TenantName;
+
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author olaa
+ */
+public class MockTenantCost implements TenantCost {
+
+ private Set<YearMonth> monthsOfMetering = Collections.emptySet();
+ private List<CostInfo> costInfoList = Collections.emptyList();
+
+ @Override
+ public Set<YearMonth> monthsWithMetering(TenantName tenantName) {
+ return monthsOfMetering;
+ }
+
+ @Override
+ public List<CostInfo> getTenantCostOfMonth(TenantName tenantName, YearMonth month) {
+ return costInfoList;
+ }
+
+ public void setMonthsWithMetering(Set<YearMonth> monthsOfMetering) {
+ this.monthsOfMetering = monthsOfMetering;
+ }
+
+ public void setCostInfoList(List<CostInfo> costInfoList) {
+ this.costInfoList = costInfoList;
+ }
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/TenantCost.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/TenantCost.java
new file mode 100644
index 00000000000..f9b7aaabcdc
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/TenantCost.java
@@ -0,0 +1,19 @@
+// 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.TenantName;
+
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author olaa
+ */
+public interface TenantCost {
+
+ Set<YearMonth> monthsWithMetering(TenantName tenantName);
+
+ List<CostInfo> getTenantCostOfMonth(TenantName tenantName, YearMonth month);
+}
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
index 10e1eb39c8a..45ead36f622 100644
--- 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
@@ -1,6 +1,8 @@
// 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.stubs;
+import com.yahoo.config.provision.ApplicationName;
+import com.yahoo.config.provision.TenantName;
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;
@@ -26,7 +28,7 @@ public class MockMeteringClient implements MeteringClient {
}
@Override
- public MeteringInfo getResourceSnapshots(String tenantName, String applicationName) {
+ public MeteringInfo getResourceSnapshots(TenantName tenantName, ApplicationName applicationName) {
return meteringInfo.orElseGet(() -> {
ResourceAllocation emptyAllocation = new ResourceAllocation(0, 0, 0);
return new MeteringInfo(emptyAllocation, emptyAllocation, emptyAllocation, Collections.emptyMap());