diff options
author | Harald Musum <musum@verizonmedia.com> | 2023-10-16 14:14:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-16 14:14:36 +0200 |
commit | ec5a429b24fba754c97c3759e0ae0bb466956c91 (patch) | |
tree | 9e209b32cd0b880eb2e66e147fce99e95cdc4cf6 | |
parent | ac5e479fd653895f36effcc97bcb2935b19e7841 (diff) | |
parent | 48f117e55853568ad4eddd5b4de2cd08dc4d3ddd (diff) |
Merge pull request #28944 from vespa-engine/hmusum/stop-using-name-per-application
Stop using name for each application
6 files changed, 15 insertions, 34 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 0aa07e93010..6fe7017e3b7 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 @@ -34,8 +34,7 @@ public class MockPricingController implements PricingController { BigDecimal appTotalAmount = listPrice.add(supportLevelCost).add(enclaveDiscount).add(volumeDiscount); List<PriceInformation> appPrices = applicationResources.stream() - .map(appResources -> new PriceInformation(appResources.applicationName(), - listPriceWithSupport, + .map(appResources -> new PriceInformation(listPriceWithSupport, volumeDiscount, ZERO, enclaveDiscount, @@ -45,7 +44,7 @@ public class MockPricingController implements PricingController { PriceInformation sum = PriceInformation.sum(appPrices); var committedAmountDiscount = new BigDecimal("-1.23"); var totalAmount = sum.totalAmount().add(committedAmountDiscount); - var totalPrice = new PriceInformation("total", ZERO, ZERO, committedAmountDiscount, ZERO, totalAmount); + var totalPrice = new PriceInformation(ZERO, ZERO, committedAmountDiscount, ZERO, totalAmount); return new Prices(appPrices, totalPrice); } 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 b8a67c2d425..106d9ab6bbe 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 @@ -5,7 +5,6 @@ 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 * @param memoryGb memory in Gb summed over all clusters, instances, zones * @param diskGb disk in Gb summed over all clusters, instances, zones @@ -15,18 +14,18 @@ import static java.math.BigDecimal.ZERO; * @param enclaveDiskGb disk in Gb summed over all clusters, instances, zones * @param enclaveGpuMemoryGb GPU memory in Gb summed over all clusters, instances, zones */ -public record ApplicationResources(String applicationName, BigDecimal vcpu, BigDecimal memoryGb, BigDecimal diskGb, +public record ApplicationResources(BigDecimal vcpu, BigDecimal memoryGb, BigDecimal diskGb, BigDecimal gpuMemoryGb, BigDecimal enclaveVcpu, BigDecimal enclaveMemoryGb, BigDecimal enclaveDiskGb, BigDecimal enclaveGpuMemoryGb) { - public static ApplicationResources create(String applicationName, BigDecimal vcpu, BigDecimal memoryGb, + public static ApplicationResources create(BigDecimal vcpu, BigDecimal memoryGb, BigDecimal diskGb, BigDecimal gpuMemoryGb) { - return new ApplicationResources(applicationName, vcpu, memoryGb, diskGb, gpuMemoryGb, ZERO, ZERO, ZERO, ZERO); + return new ApplicationResources(vcpu, memoryGb, diskGb, gpuMemoryGb, ZERO, ZERO, ZERO, ZERO); } - public static ApplicationResources createEnclave(String applicationName, BigDecimal vcpu, BigDecimal memoryGb, + public static ApplicationResources createEnclave(BigDecimal vcpu, BigDecimal memoryGb, BigDecimal diskGb, BigDecimal gpuMemoryGb) { - return new ApplicationResources(applicationName, ZERO, ZERO, ZERO, ZERO, vcpu, memoryGb, diskGb, gpuMemoryGb); + return new ApplicationResources(ZERO, ZERO, ZERO, ZERO, vcpu, memoryGb, diskGb, gpuMemoryGb); } public boolean enclave() { return enclaveVcpu().compareTo(ZERO) > 0; } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PriceInformation.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PriceInformation.java index 2c37b122b04..50463553f8e 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PriceInformation.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/PriceInformation.java @@ -6,10 +6,10 @@ import java.util.List; import static java.math.BigDecimal.ZERO; -public record PriceInformation(String applicationName, BigDecimal listPriceWithSupport, BigDecimal volumeDiscount, +public record PriceInformation(BigDecimal listPriceWithSupport, BigDecimal volumeDiscount, BigDecimal committedAmountDiscount, BigDecimal enclaveDiscount, BigDecimal totalAmount) { - public static PriceInformation empty() { return new PriceInformation("default", ZERO, ZERO, ZERO, ZERO, ZERO); } + public static PriceInformation empty() { return new PriceInformation(ZERO, ZERO, ZERO, ZERO, ZERO); } public static PriceInformation sum(List<PriceInformation> priceInformationList) { var result = PriceInformation.empty(); @@ -19,8 +19,7 @@ public record PriceInformation(String applicationName, BigDecimal listPriceWithS } public PriceInformation add(PriceInformation priceInformation) { - return new PriceInformation("accumulated", - this.listPriceWithSupport().add(priceInformation.listPriceWithSupport()), + return new PriceInformation(this.listPriceWithSupport().add(priceInformation.listPriceWithSupport()), this.volumeDiscount().add(priceInformation.volumeDiscount()), this.committedAmountDiscount().add(priceInformation.committedAmountDiscount()), this.enclaveDiscount().add(priceInformation.enclaveDiscount()), diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/Prices.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/Prices.java index 2ebd6ba5d38..650a07c51e0 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/Prices.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/pricing/Prices.java @@ -5,10 +5,4 @@ import java.util.List; public record Prices(List<PriceInformation> priceInformationApplications, PriceInformation totalPriceInformation) { - public PriceInformation get(String applicationName) { - return priceInformationApplications.stream() - .filter(priceInformation -> priceInformation.applicationName().equals(applicationName)) - .findFirst().orElseThrow(() -> new IllegalArgumentException("Unknown application name " + applicationName)); - } - } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java index 48ddd59e3f2..6ef247c5b41 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java @@ -152,7 +152,6 @@ public class PricingApiHandler extends ThreadedHttpRequestHandler { private ApplicationResources applicationResources(String appResourcesString) { List<String> elements = Arrays.stream(appResourcesString.split(",")).toList(); - var applicationName = "default"; var vcpu = ZERO; var memoryGb = ZERO; var diskGb = ZERO; @@ -165,8 +164,6 @@ public class PricingApiHandler extends ThreadedHttpRequestHandler { for (var element : keysAndValues(elements)) { var value = element.getSecond(); switch (element.getFirst().toLowerCase()) { - case "name" -> applicationName = value; - case "vcpu" -> vcpu = new BigDecimal(value); case "memorygb" -> memoryGb = new BigDecimal(value); case "diskgb" -> diskGb = new BigDecimal(value); @@ -181,7 +178,7 @@ public class PricingApiHandler extends ThreadedHttpRequestHandler { } } - return new ApplicationResources(applicationName, vcpu, memoryGb, diskGb, gpuMemoryGb, + return new ApplicationResources(vcpu, memoryGb, diskGb, gpuMemoryGb, enclaveVcpu, enclaveMemoryGb, enclaveDiskGb, enclaveGpuMemoryGb); } @@ -218,12 +215,10 @@ public class PricingApiHandler extends ThreadedHttpRequestHandler { private static void applicationPrices(Cursor applicationPricesArray, List<PriceInformation> applicationPrices, PriceParameters priceParameters) { applicationPrices.forEach(priceInformation -> { var element = applicationPricesArray.addObject(); - element.setString("name", priceInformation.applicationName()); var array = element.setArray("priceInfo"); addItem(array, supportLevelDescription(priceParameters), priceInformation.listPriceWithSupport()); addItem(array, "Enclave", priceInformation.enclaveDiscount()); addItem(array, "Volume discount", priceInformation.volumeDiscount()); - }); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java index c1f9c5db769..63636b3ff20 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandlerTest.java @@ -26,7 +26,6 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { { "applications": [ { - "name": "app1", "priceInfo": [ {"description": "Basic support unit price", "amount": "2240.00"}, {"description": "Volume discount", "amount": "-5.64"} @@ -49,7 +48,6 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { { "applications": [ { - "name": "app1", "priceInfo": [ {"description": "Basic support unit price", "amount": "2240.00"}, {"description": "Enclave", "amount": "-15.12"}, @@ -73,7 +71,6 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { { "applications": [ { - "name": "app1", "priceInfo": [ {"description": "Commercial support unit price", "amount": "3200.00"}, {"description": "Enclave", "amount": "-15.12"}, @@ -97,7 +94,6 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { { "applications": [ { - "name": "app1", "priceInfo": [ {"description": "Commercial support unit price", "amount": "2000.00"}, {"description": "Enclave", "amount": "-15.12"}, @@ -105,7 +101,6 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { ] }, { - "name": "app2", "priceInfo": [ {"description": "Commercial support unit price", "amount": "2000.00"}, {"description": "Enclave", "amount": "-15.12"}, @@ -160,7 +155,7 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { * price will be 20000 + 2000 + 200 */ String urlEncodedPriceInformation1App(PricingInfo.SupportLevel supportLevel) { - return "application=" + URLEncoder.encode("name=app1,vcpu=2,memoryGb=2,diskGb=20,gpuMemoryGb=0", UTF_8) + + return "application=" + URLEncoder.encode("vcpu=2,memoryGb=2,diskGb=20,gpuMemoryGb=0", UTF_8) + "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=100"; } @@ -170,7 +165,7 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { * price will be 20000 + 2000 + 200 */ String urlEncodedPriceInformation1AppEnclave(PricingInfo.SupportLevel supportLevel) { - return "application=" + URLEncoder.encode("name=app1,enclaveVcpu=2,enclaveMemoryGb=2,enclaveDiskGb=20,enclaveGpuMemoryGb=0", UTF_8) + + return "application=" + URLEncoder.encode("enclaveVcpu=2,enclaveMemoryGb=2,enclaveDiskGb=20,enclaveGpuMemoryGb=0", UTF_8) + "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=100"; } @@ -179,8 +174,8 @@ public class PricingApiHandlerTest extends ControllerContainerCloudTest { * 1 node, with 1 vcpu, 1 Gb memory, 10 Gb disk and no GPU */ String urlEncodedPriceInformation2AppsEnclave(PricingInfo.SupportLevel supportLevel) { - return "application=" + URLEncoder.encode("name=app1,enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) + - "&application=" + URLEncoder.encode("name=app2,enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) + + return "application=" + URLEncoder.encode("enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) + + "&application=" + URLEncoder.encode("enclaveVcpu=1,enclaveMemoryGb=1,enclaveDiskGb=10,enclaveGpuMemoryGb=0", UTF_8) + "&supportLevel=" + supportLevel.name().toLowerCase() + "&committedSpend=0"; } |