blob: 871f51689d5ca5e55b214b5a5346bc72c51453dd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// 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.PriceInformation;
import com.yahoo.vespa.hosted.controller.api.integration.pricing.PricingController;
import com.yahoo.vespa.hosted.controller.api.integration.pricing.PricingInfo;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
public class MockPricingController implements PricingController {
@Override
public PriceInformation price(List<ClusterResources> clusterResources, PricingInfo pricingInfo, Plan plan) {
BigDecimal listPrice = BigDecimal.valueOf(clusterResources.stream()
.mapToDouble(resources -> resources.nodes() *
(resources.nodeResources().vcpu() * 1000 +
resources.nodeResources().memoryGb() * 100 +
resources.nodeResources().diskGb() * 10))
.sum())
.setScale(2, RoundingMode.HALF_UP);
BigDecimal volumeDiscount = new BigDecimal("-5.00");
BigDecimal committedAmountDiscount = new BigDecimal("0.00");
BigDecimal enclaveDiscount = new BigDecimal("0.00");
BigDecimal totalAmount = listPrice.add(volumeDiscount);
return new PriceInformation(listPrice, volumeDiscount, committedAmountDiscount, enclaveDiscount, totalAmount);
}
}
|