aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-02-06 12:27:23 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2024-02-06 12:27:23 +0100
commitc4b29ec309bc118d41f90a9d8bbd94f53023e208 (patch)
treec0d3cfa696c06270daea04ab55b3908a0273f457 /config-model
parentfcca2419ded121767da85b563efb7a634533bae1 (diff)
Round redundancy up
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java4
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/RedundancyTest.java16
2 files changed, 18 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java
index 35b24f741b4..833fa89e611 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java
@@ -33,9 +33,9 @@ public class Redundancy implements StorDistributionConfig.Producer, ProtonConfig
}
/** Returns the final redundancy per group */
- public int finalRedundancy() { return effectiveFinalRedundancy()/groups; }
+ public int finalRedundancy() { return (int)Math.ceil((double)effectiveFinalRedundancy()/groups); }
- public int readyCopies() { return effectiveReadyCopies()/groups; }
+ public int readyCopies() { return (int)Math.ceil((double)effectiveReadyCopies()/groups); }
public int groups() { return groups; }
public int totalNodes() { return totalNodes; }
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/RedundancyTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/RedundancyTest.java
index 77797d91d3a..070ab10c805 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/RedundancyTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/RedundancyTest.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.model.content;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -26,4 +27,19 @@ public class RedundancyTest {
return r;
}
+ private static void verifyFinalRedundancy(Redundancy redundancy, int expectedFinal, int expectedEffectiveFinal) {
+ assertEquals(expectedEffectiveFinal, redundancy.effectiveFinalRedundancy());
+ assertEquals(expectedFinal, redundancy.finalRedundancy());
+ assertEquals(expectedEffectiveFinal, redundancy.effectiveReadyCopies());
+ assertEquals(expectedFinal, redundancy.readyCopies());
+ }
+
+ @Test
+ void test_that_redundancy_is_rounded_up() {
+ verifyFinalRedundancy(new Redundancy(1, 1, 1, 5, 5), 1,5);
+ verifyFinalRedundancy(new Redundancy(1, 1, 1, 5, 4), 1,4);
+ verifyFinalRedundancy(new Redundancy(1, 2, 2, 5, 10), 2,10);
+ verifyFinalRedundancy(new Redundancy(1, 2, 2, 5, 9), 2,9);
+ }
+
}