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
Modifier and TypeFieldDescriptionprivate static final boolean
private static final boolean
private static final boolean
private static final int
The Integer represent of JVM_SPEC_VERSION, for the JVM version comparison.private static final String
The raw String of java specification version.private static final String
private static final boolean
private static final org.slf4j.Logger
private OperatingSystemMXBean
private static final boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
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).static int
long
Get the number of the maximum file descriptors the system can use.int
Workaround to get the current number of process running.long
Get the number of opened filed descriptor for the runtime jvm.double
Get the system load averagestatic boolean
Check if the arch is aarch64;static boolean
isAmd64()
Check if the arch is amd64;static boolean
Check if the finish() method of GZIPOutputStream is brokenstatic boolean
isLinux()
Check if the OS is linux.static boolean
isUnix()
Check if the OS is unix.private Long
runUnixMXBeanMethod
(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.
-