From 1fc51f44fc8e4bed1074a8497a8531143fe53b09 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 26 Sep 2018 17:14:10 +0200 Subject: Make legger static and add some interface comments --- vespajlib/src/main/java/com/yahoo/io/NativeIO.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'vespajlib/src/main') diff --git a/vespajlib/src/main/java/com/yahoo/io/NativeIO.java b/vespajlib/src/main/java/com/yahoo/io/NativeIO.java index bee43a8653e..99c70b405b1 100644 --- a/vespajlib/src/main/java/com/yahoo/io/NativeIO.java +++ b/vespajlib/src/main/java/com/yahoo/io/NativeIO.java @@ -12,8 +12,11 @@ import com.sun.jna.LastErrorException; import com.sun.jna.Native; import com.sun.jna.Platform; +/** + * Provides functionality only possible through native C library. + */ public class NativeIO { - private final Logger logger = Logger.getLogger(getClass().getName()); + private final static Logger logger = Logger.getLogger(NativeIO.class.getName()); private static final int POSIX_FADV_DONTNEED = 4; // See /usr/include/linux/fadvise.h private static boolean initialized = false; private static Throwable initError = null; @@ -48,12 +51,20 @@ public class NativeIO { } } + /** + * Will hint the OS that this is will not be accessed again and should hence be dropped from the buffer cache. + * @param fd The file descriptor to drop from buffer cache. + */ public void dropFileFromCache(FileDescriptor fd) { if (initialized) { posix_fadvise(getNativeFD(fd), 0, 0, POSIX_FADV_DONTNEED); } } + /** + * Will hint the OS that this is will not be accessed again and should hence be dropped from the buffer cache. + * @param file File to drop from buffer cache + */ public void dropFileFromCache(File file) { try { dropFileFromCache(new FileInputStream(file).getFD()); -- cgit v1.2.3