diff options
author | Andreas Eriksen <andreer@verizonmedia.com> | 2020-09-08 12:59:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 12:59:02 +0200 |
commit | 2853e1656ef4607c379208a839e5d6d8a08eed5b (patch) | |
tree | 5abcbbea12e4a7f46269a18b3491ab49f715b459 /controller-api/src | |
parent | 90ada9b625d87887b34445c542078248e9e68a97 (diff) |
send quota budget from controller (#14178)
limiting trial account instances to $5/hr
overridable per tenant by feature flag
Diffstat (limited to 'controller-api/src')
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java index 6f162a8275e..cae768afc90 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java @@ -1,32 +1,64 @@ package com.yahoo.vespa.hosted.controller.api.integration.billing; import java.util.Objects; +import java.util.Optional; /** * Quota information transmitted to the configserver on deploy. */ public class Quota { - private final int maxClusterSize; + private final Optional<Integer> maxClusterSize; + private final Optional<Integer> budget; // in USD/hr, as calculated by NodeResources public Quota(int maxClusterSize) { - this.maxClusterSize = maxClusterSize; + this(Optional.of(maxClusterSize), Optional.empty()); } - public int maxClusterSize() { + public Quota(int maxClusterSize, int dollarsPerHour) { + this(Optional.of(maxClusterSize), Optional.of(dollarsPerHour)); + } + + public Quota(Optional<Integer> maxClusterSize, Optional<Integer> budget) { + this.maxClusterSize = Objects.requireNonNull(maxClusterSize); + this.budget = Objects.requireNonNull(budget); + } + + public Optional<Integer> maxClusterSize() { return maxClusterSize; } + public Optional<Integer> budget() { + return budget; + } + + public Quota withMaxClusterSize(int clusterSize) { + return new Quota(Optional.of(clusterSize), budget); + } + + public Quota withBudget(int budget) { + return new Quota(maxClusterSize, Optional.of(budget)); + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Quota quota = (Quota) o; - return maxClusterSize == quota.maxClusterSize; + return maxClusterSize.equals(quota.maxClusterSize) && + budget.equals(quota.budget); } @Override public int hashCode() { - return Objects.hash(maxClusterSize); + return Objects.hash(maxClusterSize, budget); + } + + @Override + public String toString() { + return "Quota{" + + "maxClusterSize=" + maxClusterSize + + ", budget=" + budget + + '}'; } } |