This is an automated email from the ASF dual-hosted git repository.

dschneider pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new b1ba8fd  GEODE-4583: remove getAnyInstance calls (#1407)
b1ba8fd is described below

commit b1ba8fd5c94d6f97db7d80ebf7d557f8e720dbae
Author: Darrel Schneider <dschnei...@pivotal.io>
AuthorDate: Thu Feb 8 12:25:58 2018 -0800

    GEODE-4583: remove getAnyInstance calls (#1407)
    
    getAnyInstance was being used to get the old logger.
    Now the class declares a static log4j logger and uses it.
---
 .../geode/internal/shared/NativeCallsJNAImpl.java  | 46 +++++++++-------------
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/shared/NativeCallsJNAImpl.java
 
b/geode-core/src/main/java/org/apache/geode/internal/shared/NativeCallsJNAImpl.java
index f6204f4..40f3f89 100644
--- 
a/geode-core/src/main/java/org/apache/geode/internal/shared/NativeCallsJNAImpl.java
+++ 
b/geode-core/src/main/java/org/apache/geode/internal/shared/NativeCallsJNAImpl.java
@@ -40,10 +40,11 @@ import com.sun.jna.Pointer;
 import com.sun.jna.Structure;
 import com.sun.jna.ptr.IntByReference;
 import com.sun.jna.win32.StdCallLibrary;
+import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.SystemFailure;
-import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.internal.cache.DiskStoreImpl;
+import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.process.signal.Signal;
 
 
@@ -59,6 +60,8 @@ import org.apache.geode.internal.process.signal.Signal;
  */
 public class NativeCallsJNAImpl {
 
+  private static final Logger logger = LogService.getLogger();
+
   // no instance allowed
   private NativeCallsJNAImpl() {}
 
@@ -281,20 +284,13 @@ public class NativeCallsJNAImpl {
 
     @Override
     public void preBlow(String path, long maxSize, boolean preAllocate) throws 
IOException {
-      final org.apache.geode.LogWriter logger;
-      if (InternalDistributedSystem.getAnyInstance() != null) {
-        logger = InternalDistributedSystem.getAnyInstance().getLogWriter();
-      } else {
-        logger = null;
-      }
-
-      if (logger != null && logger.fineEnabled()) {
-        logger.fine("DEBUG preBlow called for path = " + path);
+      if (logger.isDebugEnabled()) {
+        logger.debug("DEBUG preBlow called for path = " + path);
       }
       if (!preAllocate || !hasFallocate(path)) {
         super.preBlow(path, maxSize, preAllocate);
-        if (logger != null && logger.fineEnabled()) {
-          logger.fine("DEBUG preBlow super.preBlow 1 called for path = " + 
path);
+        if (logger.isDebugEnabled()) {
+          logger.debug("DEBUG preBlow super.preBlow 1 called for path = " + 
path);
         }
         return;
       }
@@ -304,8 +300,8 @@ public class NativeCallsJNAImpl {
         fd = createFD(path, 00644);
         if (!isOnLocalFileSystem(path)) {
           super.preBlow(path, maxSize, preAllocate);
-          if (logger != null && logger.fineEnabled()) {
-            logger.fine("DEBUG preBlow super.preBlow 2 called as path = " + 
path
+          if (logger.isDebugEnabled()) {
+            logger.debug("DEBUG preBlow super.preBlow 2 called as path = " + 
path
                 + " not on local file system");
           }
           if (DiskStoreImpl.TEST_NO_FALLOC_DIRS != null) {
@@ -317,13 +313,13 @@ public class NativeCallsJNAImpl {
         if (DiskStoreImpl.TEST_CHK_FALLOC_DIRS != null) {
           DiskStoreImpl.TEST_CHK_FALLOC_DIRS.add(path);
         }
-        if (logger != null && logger.fineEnabled()) {
-          logger.fine("DEBUG preBlow posix_fallocate called for path = " + path
+        if (logger.isDebugEnabled()) {
+          logger.debug("DEBUG preBlow posix_fallocate called for path = " + 
path
               + " and ret = 0 maxsize = " + maxSize);
         }
       } catch (LastErrorException le) {
-        if (logger != null && logger.fineEnabled()) {
-          logger.fine("DEBUG preBlow posix_fallocate called for path = " + 
path + " and ret = "
+        if (logger.isDebugEnabled()) {
+          logger.debug("DEBUG preBlow posix_fallocate called for path = " + 
path + " and ret = "
               + le.getErrorCode() + " maxsize = " + maxSize);
         }
         // check for no space left on device
@@ -343,8 +339,8 @@ public class NativeCallsJNAImpl {
         }
         if (unknownError) {
           super.preBlow(path, maxSize, preAllocate);
-          if (logger != null && logger.infoEnabled()) {
-            logger.fine("DEBUG preBlow super.preBlow 3 called for path = " + 
path);
+          if (logger.isDebugEnabled()) {
+            logger.debug("DEBUG preBlow super.preBlow 3 called for path = " + 
path);
           }
         }
       }
@@ -675,12 +671,6 @@ public class NativeCallsJNAImpl {
      * even if it on local file system for now.
      */
     public boolean isOnLocalFileSystem(final String path) {
-      final org.apache.geode.LogWriter logger;
-      if (InternalDistributedSystem.getAnyInstance() != null) {
-        logger = InternalDistributedSystem.getAnyInstance().getLogWriter();
-      } else {
-        logger = null;
-      }
       if (!isStatFSEnabled) {
         // if (logger != null && logger.fineEnabled()) {
         // logger.info("DEBUG isOnLocalFileSystem returning false 1 for path = 
" + path);
@@ -710,8 +700,8 @@ public class NativeCallsJNAImpl {
         } catch (LastErrorException le) {
           // ignoring it as NFS mounted can give this exception
           // and we just want to retry to remove transient problem.
-          if (logger != null && logger.fineEnabled()) {
-            logger.fine("DEBUG isOnLocalFileSystem got ex = " + le + " msg = " 
+ le.getMessage());
+          if (logger.isDebugEnabled()) {
+            logger.debug("DEBUG isOnLocalFileSystem got ex = " + le + " msg = 
" + le.getMessage());
           }
         }
       }

-- 
To stop receiving notification emails like this one, please contact
dschnei...@apache.org.

Reply via email to