aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2021-10-18 16:39:15 +0200
committerMartin Polden <mpolden@mpolden.no>2021-10-18 16:39:15 +0200
commit3a5280777b8e55d58a366870f926e01a44b9325d (patch)
tree059457b27f746ae892e9c35a7a3e1b53a69d5149 /vespajlib
parentc94e21087778f47afe90d277ef95d01956e74dfc (diff)
Round success factor to two decimals
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java
index 1bf84035c82..9f27ac507c9 100644
--- a/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java
+++ b/vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java
@@ -4,6 +4,8 @@ package com.yahoo.concurrent.maintenance;
import com.google.common.util.concurrent.UncheckedTimeoutException;
import com.yahoo.net.HostName;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
@@ -94,7 +96,8 @@ public abstract class Maintainer implements Runnable {
/** Convenience methods to convert attempts and failures into a success factor */
protected final double asSuccessFactor(int attempts, int failures) {
- return attempts == 0 ? 1.0 : 1 - (double)failures / attempts;
+ double factor = attempts == 0 ? 1.0 : 1 - (double)failures / attempts;
+ return new BigDecimal(factor).setScale(2, RoundingMode.HALF_UP).doubleValue();
}
/** Returns the interval at which this job is set to run */