Package org.apache.druid.utils
Class JvmUtils
- java.lang.Object
-
- org.apache.druid.utils.JvmUtils
-
public class JvmUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
UNKNOWN_VERSION
-
Constructor Summary
Constructors Constructor Description JvmUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
getCurrentThreadCpuTime()
Returns the total CPU time for current thread.static RuntimeInfo
getRuntimeInfo()
static boolean
isIsJava9Compatible()
static boolean
isThreadCpuTimeEnabled()
static int
majorVersion()
Returns the major version of the current Java runtime for Java 9 and above.static void
resetTestsToDefaultRuntimeInfo()
Only for testing.static <T> T
safeAccumulateThreadCpuTime(AtomicLong accumulator, Supplier<T> function)
Executes and returns the value offunction
.static long
safeGetThreadCpuTime()
static List<URL>
systemClassPath()
-
-
-
Field Detail
-
UNKNOWN_VERSION
public static final int UNKNOWN_VERSION
- See Also:
- Constant Field Values
-
-
Method Detail
-
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_VERSION
if the major version cannot be determined. This is a negative number and is therefore lower than all valid versions.
-
isIsJava9Compatible
public static boolean isIsJava9Compatible()
-
getRuntimeInfo
public static RuntimeInfo getRuntimeInfo()
-
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
public static <T> T safeAccumulateThreadCpuTime(AtomicLong accumulator, Supplier<T> function)
Executes and returns the value offunction
. Also accumulates the CPU time taken for the function (as reported bygetCurrentThreadCpuTime()
into {@param accumulator}.
-
resetTestsToDefaultRuntimeInfo
public static void resetTestsToDefaultRuntimeInfo()
Only for testing.
-
-