You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by li...@apache.org on 2019/02/21 07:31:14 UTC

[incubator-iotdb] branch fix_OpenFileNumUtilTest_failure_lr updated: add warn log about unsupported OS for OpenFileNumUtil getting Pid

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

liurui pushed a commit to branch fix_OpenFileNumUtilTest_failure_lr
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git


The following commit(s) were added to refs/heads/fix_OpenFileNumUtilTest_failure_lr by this push:
     new f3801b1  add warn log about unsupported OS for OpenFileNumUtil getting Pid
f3801b1 is described below

commit f3801b1a0c85a060a6d2a8a6bcd4d81cfa351aff
Author: liuruiyiyang <24...@qq.com>
AuthorDate: Thu Feb 21 15:30:50 2019 +0800

    add warn log about unsupported OS for OpenFileNumUtil getting Pid
---
 .../java/org/apache/iotdb/db/utils/OpenFileNumUtil.java     | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java b/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java
index 9a26ead..cf0c24b 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/utils/OpenFileNumUtil.java
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
 // Notice : statistics in this class may not be accurate because of limited user authority.
 public class OpenFileNumUtil {
 
-  private static final Logger log = LoggerFactory.getLogger(OpenFileNumUtil.class);
+  private static final Logger LOGGER = LoggerFactory.getLogger(OpenFileNumUtil.class);
   private static final int PID_ERROR_CODE = -1;
   private static final int UNSUPPORTED_OS_ERROR_CODE = -2;
   private static final int UNKNOWN_STATISTICS_ERROR_CODE = -3;
@@ -97,7 +97,10 @@ public class OpenFileNumUtil {
     int iotdbPid = -1;
     Process pro1;
     Runtime r = Runtime.getRuntime();
-    String osName = System.getProperty("os.name").toLowerCase();
+    // System.getProperty("os.name") can detect which type of OS is using now.
+    // this code can detect Windows, Mac, Unix and Solaris.
+    String os = System.getProperty("os.name");
+    String osName = os.toLowerCase();
     if (osName.startsWith(LINUX_OS_NAME) || osName.startsWith(MAC_OS_NAME)) {
       try {
         String command;
@@ -122,8 +125,10 @@ public class OpenFileNumUtil {
         in1.close();
         pro1.destroy();
       } catch (IOException e) {
-        log.error("Cannot get pid of IoTDB process. ", e);
+        LOGGER.error("Cannot get pid of IoTDB process because {}", e.getMessage());
       }
+    } else {
+      LOGGER.warn("Unsupported OS {} for OpenFileNumUtil getting Pid.", os);
     }
     return iotdbPid;
   }
@@ -199,7 +204,7 @@ public class OpenFileNumUtil {
       in.close();
       pro.destroy();
     } catch (Exception e) {
-      log.error("Cannot get open file number of IoTDB process.", e);
+      LOGGER.error("Cannot get open file number of IoTDB process because {}", e.getMessage());
     }
     return resultMap;
   }