diff options
Diffstat (limited to 'vespajlib/src/main')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/concurrent/maintenance/Maintainer.java | 5 | ||||
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/io/NativeIO.java | 15 |
2 files changed, 16 insertions, 4 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 */ diff --git a/vespajlib/src/main/java/com/yahoo/io/NativeIO.java b/vespajlib/src/main/java/com/yahoo/io/NativeIO.java index 34e68edcedd..3cb1cdf5242 100644 --- a/vespajlib/src/main/java/com/yahoo/io/NativeIO.java +++ b/vespajlib/src/main/java/com/yahoo/io/NativeIO.java @@ -19,14 +19,19 @@ import com.sun.jna.Platform; */ public class NativeIO { private final static Logger logger = Logger.getLogger(NativeIO.class.getName()); + private final static String DISABLE_NATIVE_IO = "DISABLE_NATIVE_IO"; private static final int POSIX_FADV_DONTNEED = 4; // See /usr/include/linux/fadvise.h private static boolean initialized = false; + private static boolean disabled = false; private static Throwable initError = null; static { try { if (Platform.isLinux()) { - Native.register(Platform.C_LIBRARY_NAME); - initialized = true; + disabled = System.getenv().containsKey(DISABLE_NATIVE_IO); + if (!disabled) { + Native.register(Platform.C_LIBRARY_NAME); + initialized = true; + } } } catch (Throwable throwable) { initError = throwable; @@ -40,7 +45,11 @@ public class NativeIO { public NativeIO() { if (!initialized) { - logger.warning("native IO not possible due to " + getError().getMessage()); + if (disabled) { + logger.info("Native IO has been disable explicit via system property " + DISABLE_NATIVE_IO); + } else { + logger.warning("Native IO not possible due to " + getError().getMessage()); + } } } |