Class JvmPidDiscoverer

java.lang.Object
org.apache.druid.java.util.metrics.JvmPidDiscoverer
All Implemented Interfaces:
PidDiscoverer

public class JvmPidDiscoverer extends Object implements PidDiscoverer
For systems that for whatever reason cannot use Sigar (through org.apache.druid.java.util.metrics.SigarPidDiscoverer ), this attempts to get the PID from the JVM "name".
  • Method Details

    • instance

      public static JvmPidDiscoverer instance()
    • getPid

      public long getPid()
      Returns the PID as a best guess. This uses methods that are not guaranteed to actually be the PID.

      TODO: switch to ProcessHandle.current().getPid() for java9 potentially

      Specified by:
      getPid in interface PidDiscoverer
      Returns:
      the PID of the current jvm if available
      Throws:
      RuntimeException - if the pid cannot be determined