Package org.apache.druid.utils
Class JvmUtils
java.lang.Object
org.apache.druid.utils.JvmUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longReturns the total CPU time for current thread.static RuntimeInfoDeprecated.static longGet the total memory of the machine it is running on.static booleanstatic intReturns the major version of the current Java runtime for Java 9 and above.static <T> TsafeAccumulateThreadCpuTime(AtomicLong accumulator, Supplier<T> function) Executes and returns the value offunction.static long
-
Field Details
-
UNKNOWN_VERSION
public static final int UNKNOWN_VERSION- See Also:
-
-
Constructor Details
-
JvmUtils
public JvmUtils()
-
-
Method Details
-
majorVersion
public static int majorVersion()Returns the major version of the current Java runtime for Java 9 and above. For example: 9, 11, 17, etc. Returns 1 for Java 8 and earlier. ReturnsUNKNOWN_VERSIONif the major version cannot be determined. This is a negative number and is therefore lower than all valid versions. -
getRuntimeInfo
Deprecated.Deprecated, injectRuntimeInfoinstead of using this function. -
isThreadCpuTimeEnabled
public static boolean isThreadCpuTimeEnabled() -
safeGetThreadCpuTime
public static long safeGetThreadCpuTime() -
getCurrentThreadCpuTime
public static long getCurrentThreadCpuTime()Returns the total CPU time for current thread. This method should be called after verifying that cpu time measurement for current thread is supported by JVM- Returns:
- total CPU time for the current thread in nanoseconds.
- Throws:
UnsupportedOperationException- if the Java virtual machine does not support CPU time measurement for the current thread.
-
safeAccumulateThreadCpuTime
Executes and returns the value offunction. Also accumulates the CPU time taken for the function (as reported bygetCurrentThreadCpuTime()into . -
systemClassPath
-
getTotalMemory
public static long getTotalMemory()Get the total memory of the machine it is running on. This function is container aware. If the machine is running in a container, the function will return the total memory of the container. If the machine is not running in a container, the function will return the total memory of the machine.- Returns:
- the total memory of the machine it is running on in bytes.
-