aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-10-31 14:57:05 +0100
committerHarald Musum <musum@yahooinc.com>2023-10-31 14:57:05 +0100
commit6572324794d105fcf24b5d98f7405b2aea48de0b (patch)
treee2b5db8f411363213ae2688292fd0da1fd790088
parenta06b9c56ec1d65e951b94473c49e746c736dc19c (diff)
Minor cleanup
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/Quota.java13
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployNodeAllocationTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java3
3 files changed, 8 insertions, 11 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/Quota.java b/config-model-api/src/main/java/com/yahoo/config/model/api/Quota.java
index b652f9e8a68..f49bb224394 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/Quota.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/Quota.java
@@ -25,12 +25,7 @@ public class Quota {
/** The max budget in dollars per hour */
private final Optional<BigDecimal> budget;
- public Quota(Optional<Integer> maxClusterSize, Optional<Integer> budget) {
- this(maxClusterSize, budget.map(BigDecimal::new), true);
- }
-
- // TODO: Remove unused argument
- private Quota(Optional<Integer> maxClusterSize, Optional<BigDecimal> budget, boolean isDecimal) {
+ public Quota(Optional<Integer> maxClusterSize, Optional<BigDecimal> budget) {
this.maxClusterSize = Objects.requireNonNull(maxClusterSize);
this.budget = Objects.requireNonNull(budget);
}
@@ -38,15 +33,15 @@ public class Quota {
public static Quota fromSlime(Inspector inspector) {
var clusterSize = SlimeUtils.optionalInteger(inspector.field("clusterSize"));
var budget = budgetFromSlime(inspector.field("budget"));
- return new Quota(clusterSize.stream().boxed().findFirst(), budget, true);
+ return new Quota(clusterSize.stream().boxed().findFirst(), budget);
}
public Quota withBudget(BigDecimal budget) {
- return new Quota(this.maxClusterSize, Optional.of(budget), true);
+ return new Quota(this.maxClusterSize, Optional.of(budget));
}
public Quota withClusterSize(int clusterSize) {
- return new Quota(Optional.of(clusterSize), this.budget, true);
+ return new Quota(Optional.of(clusterSize), this.budget);
}
public Slime toSlime() {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployNodeAllocationTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployNodeAllocationTest.java
index 44344b6d394..e45af84f6f0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployNodeAllocationTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployNodeAllocationTest.java
@@ -26,6 +26,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import static com.yahoo.vespa.config.server.deploy.DeployTester.createHostedModelFactory;
+import static java.math.BigDecimal.valueOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -79,7 +80,7 @@ public class HostedDeployNodeAllocationTest {
tester.deployApp("src/test/apps/hosted/", new PrepareParams.Builder()
.vespaVersion("7.3")
.containerEndpoints(endpoints)
- .quota(new Quota(Optional.of(4), Optional.of(0))));
+ .quota(new Quota(Optional.of(4), Optional.of(valueOf(0)))));
fail("Expected to get a QuotaExceededException");
} catch (QuotaExceededException e) {
assertEquals("main: The resources used cost $1.02 but your quota is $0.00: Contact support to upgrade your plan.", e.getMessage());
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
index 867a958cbe3..7fcaae05224 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import static com.yahoo.vespa.config.server.session.SessionData.APPLICATION_ID_PATH;
import static com.yahoo.vespa.config.server.session.SessionData.SESSION_DATA_PATH;
import static com.yahoo.vespa.config.server.zookeeper.ZKApplication.SESSIONSTATE_ZK_SUBPATH;
+import static java.math.BigDecimal.valueOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -144,7 +145,7 @@ public class SessionZooKeeperClientTest {
@Test
public void require_quota_written_and_parsed() {
- var quota = Optional.of(new Quota(Optional.of(23), Optional.of(32)));
+ var quota = Optional.of(new Quota(Optional.of(23), Optional.of(valueOf(32))));
var zkc = createSessionZKClient(4);
zkc.writeQuota(quota);
assertEquals(quota, zkc.readQuota());