diff options
author | Harald Musum <musum@yahooinc.com> | 2023-10-13 15:14:48 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-10-13 15:14:48 +0200 |
commit | 1fe61e8329e25b41576286b24e867f822226c778 (patch) | |
tree | 6f293914c7691d74c955616c45ee2dac0dbd13e5 /controller-api/src/main | |
parent | 4941bdf24e4ab4ac09348f9d50d65bb4d8112c50 (diff) |
Remove support for legacy price calculations from API
Diffstat (limited to 'controller-api/src/main')
4 files changed, 18 insertions, 28 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java index 8ea1882bff6..0aa07e93010 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java @@ -1,7 +1,6 @@ // Copyright Vespa.ai. 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.config.provision.ClusterResources; import com.yahoo.vespa.hosted.controller.api.integration.billing.Plan; import com.yahoo.vespa.hosted.controller.api.integration.pricing.ApplicationResources; import com.yahoo.vespa.hosted.controller.api.integration.pricing.PriceInformation; @@ -18,25 +17,6 @@ import static java.math.BigDecimal.valueOf; public class MockPricingController implements PricingController { - // TODO: Remove when not in use anymore - @Override - public PriceInformation price(List<ClusterResources> clusterResources, PricingInfo pricingInfo, Plan plan) { - BigDecimal listPrice = valueOf(clusterResources.stream() - .mapToDouble(resources -> resources.nodes() * - (resources.nodeResources().vcpu() * 1000 + - resources.nodeResources().memoryGb() * 100 + - resources.nodeResources().diskGb() * 10)) - .sum()); - - BigDecimal supportLevelCost = pricingInfo.supportLevel() == BASIC ? new BigDecimal("-160.00") : new BigDecimal("800.00"); - BigDecimal listPriceWithSupport = listPrice.add(supportLevelCost); - BigDecimal enclaveDiscount = pricingInfo.enclave() ? new BigDecimal("-15.1234") : BigDecimal.ZERO; - BigDecimal volumeDiscount = new BigDecimal("-5.64315634"); - BigDecimal committedAmountDiscount = new BigDecimal("-1.23"); - BigDecimal totalAmount = listPrice.add(supportLevelCost).add(enclaveDiscount).add(volumeDiscount).add(committedAmountDiscount); - return new PriceInformation("default", listPriceWithSupport, volumeDiscount, committedAmountDiscount, enclaveDiscount, totalAmount); - } - @Override public Prices priceForApplications(List<ApplicationResources> applicationResources, PricingInfo pricingInfo, Plan plan) { ApplicationResources resources = applicationResources.get(0); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/ApplicationResources.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/ApplicationResources.java index 5c6de406a55..fa742c27486 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/ApplicationResources.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/ApplicationResources.java @@ -2,6 +2,8 @@ package com.yahoo.vespa.hosted.controller.api.integration.pricing; import java.math.BigDecimal; +import static java.math.BigDecimal.ZERO; + /** * @param applicationName name of the application * @param vcpu vcpus summed over all clusters, instances, zones @@ -17,5 +19,14 @@ public record ApplicationResources(String applicationName, BigDecimal vcpu, BigD BigDecimal gpuMemoryGb, BigDecimal enclaveVcpu, BigDecimal enclaveMemoryGb, BigDecimal enclaveDiskGb, BigDecimal enclaveGpuMemoryGb) { -} + public static ApplicationResources create(String applicationName, BigDecimal vcpu, BigDecimal memoryGb, + BigDecimal diskGb, BigDecimal gpuMemoryGb) { + return new ApplicationResources(applicationName, vcpu, memoryGb, diskGb, gpuMemoryGb, ZERO, ZERO, ZERO, ZERO); + } + public static ApplicationResources createEnclave(String applicationName, BigDecimal vcpu, BigDecimal memoryGb, + BigDecimal diskGb, BigDecimal gpuMemoryGb) { + return new ApplicationResources(applicationName, ZERO, ZERO, ZERO, ZERO, vcpu, memoryGb, diskGb, gpuMemoryGb); + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingController.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingController.java index 23d5f81dfb7..7b082932588 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingController.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingController.java @@ -1,7 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.pricing; -import com.yahoo.config.provision.ClusterResources; import com.yahoo.vespa.hosted.controller.api.integration.billing.Plan; import java.util.List; @@ -13,9 +12,6 @@ import java.util.List; */ public interface PricingController { - // TODO: Legacy, will be removed when not in use anymore - PriceInformation price(List<ClusterResources> clusterResources, PricingInfo pricingInfo, Plan plan); - /** * * @param applicationResources resources used by an application diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingInfo.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingInfo.java index 1ab149d083f..ba6f1939fc5 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingInfo.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PricingInfo.java @@ -1,11 +1,14 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.controller.api.integration.pricing; -// TODO: Use BigDecimal for committedHourlyAmount -public record PricingInfo(boolean enclave, SupportLevel supportLevel, double committedHourlyAmount) { +import java.math.BigDecimal; + +import static java.math.BigDecimal.ZERO; + +public record PricingInfo(SupportLevel supportLevel, BigDecimal committedHourlyAmount) { public enum SupportLevel { BASIC, COMMERCIAL, ENTERPRISE } - public static PricingInfo empty() { return new PricingInfo(false, SupportLevel.COMMERCIAL, 0); } + public static PricingInfo empty() { return new PricingInfo(SupportLevel.COMMERCIAL, ZERO); } } |