ProcfsBasedProcessTree (Apache Hadoop YARN Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.yarn.util, class: ProcfsBasedProcessTree

Package org.apache.hadoop.yarn.util

# Class ProcfsBasedProcessTree

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree
org.apache.hadoop.yarn.util.ProcfsBasedProcessTree

All Implemented Interfaces:
  `org.apache.hadoop.conf.Configurable`

@Private @Unstable public class ProcfsBasedProcessTree extends ResourceCalculatorProcessTree
A Proc file-system based ProcessTree. Works only on Linux.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final long`
  `JIFFY_LENGTH_IN_MILLIS`
  `static final int`
  `KB_TO_BYTES`
  `static final long`
  `PAGE_SIZE`
  `protected Map<String,org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessTreeSmapMemInfo>`
  `processSMAPTree`
  `protected Map<String,org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessInfo>`
  `processTree`
  `static final String`
  `PROCFS_CMDLINE_FILE`
  `static final String`
  `PROCFS_STAT_FILE`
  `static final String`
  `SMAPS`

  ### Fields inherited from class org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree

  `UNAVAILABLE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ProcfsBasedProcessTree(String pid)`
  `ProcfsBasedProcessTree(String pid, String procfsDir)`
  `ProcfsBasedProcessTree(String pid, String procfsDir, Clock clock)`
  Build a new process tree rooted at the pid.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `checkPidPgrpidForMatch()`
  Verify that the given process id is same as its process group id.
  `static boolean`
  `checkPidPgrpidForMatch(String _pid, String procfs)`
  `boolean`
  `contains(String pid)`
  Returns boolean indicating whether pid is in process tree.
  `float`
  `getCpuUsagePercent()`
  Get the CPU usage by all the processes in the process-tree in Unix.
  `long`
  `getCumulativeCpuTime()`
  Get the CPU time in millisecond used by all the processes in the process-tree since the process-tree was created
  `List<String>`
  `getCurrentProcessIDs()`
  `String`
  `getProcessTreeDump()`
  Get a dump of the process-tree.
  `long`
  `getRssMemorySize(int olderThanAge)`
  Get the resident set size (rss) memory used by all the processes in the process-tree that are older than the passed in age.
  `long`
  `getVirtualMemorySize(int olderThanAge)`
  Get the virtual memory used by all the processes in the process-tree that are older than the passed in age.
  `static boolean`
  `isAvailable()`
  Checks if the ProcfsBasedProcessTree is available on this system.
  `static void`
  `main(String[] args)`
  Test the `ProcfsBasedProcessTree`.
  `void`
  `setConf(org.apache.hadoop.conf.Configuration conf)`
  `String`
  `toString()`
  Returns a string printing PIDs of process present in the ProcfsBasedProcessTree.
  `void`
  `updateProcessTree()`
  Update process-tree with latest state.

  ### Methods inherited from class org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree

  `getResourceCalculatorProcessTree, getRssMemorySize, getVirtualMemorySize, initialize`

  ### Methods inherited from class org.apache.hadoop.conf.Configured

  `getConf`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### PROCFS_STAT_FILE

    public static final String PROCFS_STAT_FILE
    See Also:
      - Constant Field Values

  - ### PROCFS_CMDLINE_FILE

    public static final String PROCFS_CMDLINE_FILE
    See Also:
      - Constant Field Values

  - ### PAGE_SIZE

    public static final long PAGE_SIZE

  - ### JIFFY_LENGTH_IN_MILLIS

    public static final long JIFFY_LENGTH_IN_MILLIS

  - ### SMAPS

    public static final String SMAPS
    See Also:
      - Constant Field Values

  - ### KB_TO_BYTES

    public static final int KB_TO_BYTES
    See Also:
      - Constant Field Values

  - ### processSMAPTree

    protected Map<String,org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessTreeSmapMemInfo> processSMAPTree

  - ### processTree

    protected Map<String,org.apache.hadoop.yarn.util.ProcfsBasedProcessTree.ProcessInfo> processTree

- ## Constructor Details

  - ### ProcfsBasedProcessTree

    public ProcfsBasedProcessTree(String pid)

  - ### ProcfsBasedProcessTree

    public ProcfsBasedProcessTree(String pid, String procfsDir)

  - ### ProcfsBasedProcessTree

    public ProcfsBasedProcessTree(String pid, String procfsDir, Clock clock)
    Build a new process tree rooted at the pid. This method is provided mainly for testing purposes, where the root of the proc file system can be adjusted.
    Parameters:
      `pid` - root of the process tree
      `procfsDir` - the root of a proc file system - only used for testing.
      `clock` - clock for controlling time for testing

- ## Method Details

  - ### setConf

    public void setConf(org.apache.hadoop.conf.Configuration conf)
    Specified by:
      `setConf` in interface `org.apache.hadoop.conf.Configurable`
    Overrides:
      `setConf` in class `org.apache.hadoop.conf.Configured`

  - ### isAvailable

    public static boolean isAvailable()
    Checks if the ProcfsBasedProcessTree is available on this system.
    Returns:
      true if ProcfsBasedProcessTree is available. False otherwise.

  - ### updateProcessTree

    public void updateProcessTree()
    Update process-tree with latest state. If the root-process is not alive, tree will be empty.
    Specified by:
      `updateProcessTree` in class `ResourceCalculatorProcessTree`

  - ### checkPidPgrpidForMatch

    public boolean checkPidPgrpidForMatch()
    Verify that the given process id is same as its process group id.
    Specified by:
      `checkPidPgrpidForMatch` in class `ResourceCalculatorProcessTree`
    Returns:
      true if the process id matches else return false.

  - ### checkPidPgrpidForMatch

    public static boolean checkPidPgrpidForMatch(String _pid, String procfs)

  - ### getCurrentProcessIDs

    public List<String> getCurrentProcessIDs()

  - ### getProcessTreeDump

    public String getProcessTreeDump()
    Get a dump of the process-tree.
    Specified by:
      `getProcessTreeDump` in class `ResourceCalculatorProcessTree`
    Returns:
      a string concatenating the dump of information of all the processes in the process-tree

  - ### getVirtualMemorySize

    public long getVirtualMemorySize(int olderThanAge)
    Description copied from class: `ResourceCalculatorProcessTree`
    Get the virtual memory used by all the processes in the process-tree that are older than the passed in age.
    Overrides:
      `getVirtualMemorySize` in class `ResourceCalculatorProcessTree`
    Parameters:
      `olderThanAge` - processes above this age are included in the memory addition
    Returns:
      virtual memory used by the process-tree in bytes for processes older than the specified age, `ResourceCalculatorProcessTree.UNAVAILABLE` if it cannot be calculated.

  - ### getRssMemorySize

    public long getRssMemorySize(int olderThanAge)
    Description copied from class: `ResourceCalculatorProcessTree`
    Get the resident set size (rss) memory used by all the processes in the process-tree that are older than the passed in age.
    Overrides:
      `getRssMemorySize` in class `ResourceCalculatorProcessTree`
    Parameters:
      `olderThanAge` - processes above this age are included in the memory addition
    Returns:
      rss memory used by the process-tree in bytes for processes older than specified age, `ResourceCalculatorProcessTree.UNAVAILABLE` if it cannot be calculated.

  - ### getCumulativeCpuTime

    public long getCumulativeCpuTime()
    Description copied from class: `ResourceCalculatorProcessTree`
    Get the CPU time in millisecond used by all the processes in the process-tree since the process-tree was created
    Overrides:
      `getCumulativeCpuTime` in class `ResourceCalculatorProcessTree`
    Returns:
      cumulative CPU time in millisecond since the process-tree created, `ResourceCalculatorProcessTree.UNAVAILABLE` if it cannot be calculated.

  - ### getCpuUsagePercent

    public float getCpuUsagePercent()
    Get the CPU usage by all the processes in the process-tree in Unix. Note: UNAVAILABLE will be returned in case when CPU usage is not available. It is NOT advised to return any other error code.
    Overrides:
      `getCpuUsagePercent` in class `ResourceCalculatorProcessTree`
    Returns:
      percentage CPU usage since the process-tree was created, `ResourceCalculatorProcessTree.UNAVAILABLE` if CPU usage cannot be calculated or not available.

  - ### toString

    public String toString()
    Returns a string printing PIDs of process present in the ProcfsBasedProcessTree. Output format : [pid pid ..]
    Overrides:
      `toString` in class `Object`

  - ### contains

    public boolean contains(String pid)
    Returns boolean indicating whether pid is in process tree.
    Parameters:
      `pid` - pid.
    Returns:
      if true, processTree contains pid, false, processTree does not contain pid.

  - ### main

    public static void main(String[] args)
    Test the `ProcfsBasedProcessTree`.
    Parameters:
      `args` - the pid arg.