You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by "horizonzy (via GitHub)" <gi...@apache.org> on 2023/03/02 05:00:38 UTC

[GitHub] [bookkeeper] horizonzy commented on a diff in pull request #3824: Use JNI directly for posix_fadvise

horizonzy commented on code in PR #3824:
URL: https://github.com/apache/bookkeeper/pull/3824#discussion_r1122600375


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/util/PageCacheUtil.java:
##########
@@ -18,41 +18,37 @@
 
 package org.apache.bookkeeper.util;
 
-import com.sun.jna.LastErrorException;
-import com.sun.jna.Native;
 import java.io.FileDescriptor;
 import java.lang.reflect.Field;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.common.util.nativeio.NativeIO;
+import org.apache.bookkeeper.common.util.nativeio.NativeIOImpl;
 
 /**
  * Native I/O operations.
  */
-public final class NativeIO {
-    private static final Logger LOG = LoggerFactory.getLogger(NativeIO.class);
+@UtilityClass
+@Slf4j
+public final class PageCacheUtil {
 
     private static final int POSIX_FADV_DONTNEED = 4; /* fadvise.h */
 
-    private static boolean initialized = false;
     private static boolean fadvisePossible = true;
 
+    private static final NativeIO NATIVE_IO;
+
     static {
+        NativeIO nativeIO = null;
         try {
-            Native.register("c");
-            initialized = true;
-        } catch (NoClassDefFoundError e) {
-            LOG.info("JNA not found. Native methods will be disabled.");
-        } catch (UnsatisfiedLinkError e) {
-            LOG.info("Unable to link C library. Native methods will be disabled.");
-        } catch (NoSuchMethodError e) {
-            LOG.warn("Obsolete version of JNA present; unable to register C library");
+            nativeIO = new NativeIOImpl();

Review Comment:
   We should check if `nativeIO.posix_fdavise` works or not. `new NativeIOImpl()` din't ensure `posix_fdavise` work



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org