diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-10-19 08:49:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 08:49:41 +0200 |
commit | 8c73176aba28a96523920540dd3d9a9ce5750cb0 (patch) | |
tree | 04861df01c58ba2e36c4fa6ed5cd1d7abfdd36d3 | |
parent | 3851833f09fbfc82c6b350d3503088bb1a683b07 (diff) | |
parent | 3a5280777b8e55d58a366870f926e01a44b9325d (diff) |
Merge pull request #19623 from vespa-engine/mpolden/round-up
Round success factor to two decimals
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java | 5 |
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 */ |