summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-02-20 12:52:47 +0100
committerMartin Polden <mpolden@mpolden.no>2020-02-20 12:54:08 +0100
commit2ba81cc47c9c5a69845e444ca207f3a02f652c5c (patch)
tree1767ce4aadaecbb9ec45cb9b83e5a8e2cf734058
parent6c008f178d4056e65b589c9841b8f264d3892b31 (diff)
Inline constant parameter
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/CostReportMaintainer.java4
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/metric/CostCalculator.java18
2 files changed, 10 insertions, 12 deletions
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 233213eec1f..5b792f384e5 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,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.maintenance;
-import com.yahoo.config.provision.CloudName;
import com.yahoo.config.provision.SystemName;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.NodeRepository;
@@ -34,7 +33,8 @@ public class CostReportMaintainer extends Maintainer {
@Override
protected void maintain() {
- consumer.consume(CostCalculator.resourceShareByPropertyToCsv(nodeRepository, controller(), clock, consumer.fixedAllocations(), CloudName.from("yahoo")));
+ var csv = CostCalculator.resourceShareByPropertyToCsv(nodeRepository, controller(), clock, consumer.fixedAllocations());
+ consumer.consume(csv);
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/metric/CostCalculator.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/metric/CostCalculator.java
index b68504b799e..4cc4ee0386c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/metric/CostCalculator.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/metric/CostCalculator.java
@@ -28,12 +28,12 @@ import static com.yahoo.yolean.Exceptions.uncheck;
public class CostCalculator {
private static final double SELF_HOSTED_DISCOUNT = .5;
+ private static final CloudName cloudName = CloudName.from("yahoo");
public static String resourceShareByPropertyToCsv(NodeRepository nodeRepository,
Controller controller,
Clock clock,
- Map<Property, ResourceAllocation> fixedAllocations,
- CloudName cloudName) {
+ Map<Property, ResourceAllocation> fixedAllocations) {
var date = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC")).format(clock.instant());
@@ -61,14 +61,12 @@ public class CostCalculator {
}
// Add fixed allocations from config
- if (cloudName.equals(CloudName.from("yahoo"))) {
- for (var kv : fixedAllocations.entrySet()) {
- var property = kv.getKey();
- var allocation = allocationByProperty.getOrDefault(property, ResourceAllocation.ZERO);
- var discountedFixedAllocation = kv.getValue().multiply(SELF_HOSTED_DISCOUNT);
- allocationByProperty.put(property, allocation.plus(discountedFixedAllocation));
- totalAllocation = totalAllocation.plus(discountedFixedAllocation);
- }
+ for (var kv : fixedAllocations.entrySet()) {
+ var property = kv.getKey();
+ var allocation = allocationByProperty.getOrDefault(property, ResourceAllocation.ZERO);
+ var discountedFixedAllocation = kv.getValue().multiply(SELF_HOSTED_DISCOUNT);
+ allocationByProperty.put(property, allocation.plus(discountedFixedAllocation));
+ totalAllocation = totalAllocation.plus(discountedFixedAllocation);
}
return toCsv(allocationByProperty, date, totalAllocation);