diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-10-19 13:01:09 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-10-19 13:01:09 +0200 |
commit | 94d18bf4468d14d56adc35d8289c598c621a0770 (patch) | |
tree | fdc3002396fed85eda954d6cc9695b31808a6d0a /vespajlib/src | |
parent | f996eb3c39db4c83b856495ec64984ba7fddc344 (diff) |
Diable NativeIO if environment variable DISABLE_NATIVE_IO has been defined.
Diffstat (limited to 'vespajlib/src')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/io/NativeIO.java | 15 |
1 files changed, 12 insertions, 3 deletions
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()); + } } } |