Class JvmUtils

java.lang.Object
org.apache.druid.utils.JvmUtils

public class JvmUtils extends Object
  • Field Details

  • 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. Returns UNKNOWN_VERSION if the major version cannot be determined. This is a negative number and is therefore lower than all valid versions.
    • getRuntimeInfo

      @Deprecated public static RuntimeInfo getRuntimeInfo()
      Deprecated.
      Deprecated, inject RuntimeInfo instead 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

      public static <T> T safeAccumulateThreadCpuTime(AtomicLong accumulator, Supplier<T> function)
      Executes and returns the value of function. Also accumulates the CPU time taken for the function (as reported by getCurrentThreadCpuTime() into .
    • systemClassPath

      public static List<URL> systemClassPath()