Package org.apache.hadoop.hbase.util
Class JVM
java.lang.Object
org.apache.hadoop.hbase.util.JVM
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate static final booleanprivate static final booleanprivate static final intThe Integer represent of JVM_SPEC_VERSION, for the JVM version comparison.private static final StringThe raw String of java specification version.private static final Stringprivate static final booleanprivate static final org.slf4j.Loggerprivate OperatingSystemMXBeanprivate static final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongReturn 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).static intlongGet the number of the maximum file descriptors the system can use.intWorkaround to get the current number of process running.longGet the number of opened filed descriptor for the runtime jvm.doubleGet the system load averagestatic booleanCheck if the arch is aarch64;static booleanisAmd64()Check if the arch is amd64;static booleanCheck if the finish() method of GZIPOutputStream is brokenstatic booleanisLinux()Check if the OS is linux.static booleanisUnix()Check if the OS is unix.private LongrunUnixMXBeanMethod(String mBeanMethodName) Load the implementation of UnixOperatingSystemMXBean for Oracle jvm and runs the desired method.
-
Field Details
-
LOG
-
osMbean
-
ibmvendor
-
windows
-
linux
-
amd64
-
aarch64
-
JVMVersion
-
JVM_SPEC_VERSION_STRING
The raw String of java specification version. "1.8" for java8, "9","10"... for Java 9, 10... -
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
Check if the OS is unix.- Returns:
- whether this is unix or not.
-
isLinux
Check if the OS is linux.- Returns:
- whether this is linux or not.
-
isAmd64
Check if the arch is amd64;- Returns:
- whether this is amd64 or not.
-
isAarch64
Check if the arch is aarch64;- Returns:
- whether this is aarch64 or not.
-
isGZIPOutputStreamFinishBroken
Check if the finish() method of GZIPOutputStream is broken- Returns:
- whether GZIPOutputStream.finish() is broken.
-
getJVMSpecVersion
-
runUnixMXBeanMethod
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
Get the system load average -
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.
-