Class JVM

java.lang.Object
org.apache.hadoop.hbase.util.JVM

@Private public class JVM extends Object
This class is a wrapper for the implementation of com.sun.management.UnixOperatingSystemMXBean It will decide to use the sun api or its own implementation depending on the runtime (vendor) used.
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • osMbean

    • ibmvendor

      private static final boolean ibmvendor
    • windows

      private static final boolean windows
    • linux

      private static final boolean linux
    • amd64

      private static final boolean amd64
    • aarch64

      private static final boolean aarch64
    • JVMVersion

      private static final String JVMVersion
    • JVM_SPEC_VERSION_STRING

      private static final String JVM_SPEC_VERSION_STRING
      The raw String of java specification version. "1.8" for java8, "9","10"... for Java 9, 10...
    • JVM_SPEC_VERSION

      private static final int JVM_SPEC_VERSION
      The Integer represent of JVM_SPEC_VERSION, for the JVM version comparison. Java 8, 9, 10 ... will be noted as 8, 9 10 ...
  • Constructor Details

    • JVM

      public JVM()
      Constructor. Get the running Operating System instance
  • Method Details

    • isUnix

      public static boolean isUnix()
      Check if the OS is unix.
      Returns:
      whether this is unix or not.
    • isLinux

      public static boolean isLinux()
      Check if the OS is linux.
      Returns:
      whether this is linux or not.
    • isAmd64

      public static boolean isAmd64()
      Check if the arch is amd64;
      Returns:
      whether this is amd64 or not.
    • isAarch64

      public static boolean isAarch64()
      Check if the arch is aarch64;
      Returns:
      whether this is aarch64 or not.
    • isGZIPOutputStreamFinishBroken

      public static boolean isGZIPOutputStreamFinishBroken()
      Check if the finish() method of GZIPOutputStream is broken
      Returns:
      whether GZIPOutputStream.finish() is broken.
    • getJVMSpecVersion

      public static int getJVMSpecVersion()
    • runUnixMXBeanMethod

      private Long runUnixMXBeanMethod(String mBeanMethodName)
      Load the implementation of UnixOperatingSystemMXBean for Oracle jvm and runs the desired method.
      Parameters:
      mBeanMethodName - : method to run from the interface UnixOperatingSystemMXBean
      Returns:
      the method result
    • getOpenFileDescriptorCount

      Get the number of opened filed descriptor for the runtime jvm. If Oracle java, it will use the com.sun.management interfaces. Otherwise, this methods implements it (linux only).
      Returns:
      number of open file descriptors for the jvm
    • getSystemLoadAverage

      public double getSystemLoadAverage()
      Get the system load average
      See Also:
    • getFreeMemory

      public long getFreeMemory()
      Return the physical free memory (not the JVM one, as it's not very useful as it depends on the GC), but the one from the OS as it allows a little bit more to guess if the machine is overloaded or not).
    • getNumberOfRunningProcess

      Workaround to get the current number of process running. Approach is the one described here: http://stackoverflow.com/questions/54686/how-to-get-a-list-of-current-open-windows-process-with-java
    • getMaxFileDescriptorCount

      Get the number of the maximum file descriptors the system can use. If Oracle java, it will use the com.sun.management interfaces. Otherwise, this methods implements it (linux only).
      Returns:
      max number of file descriptors the operating system can use.