Class ResourceCalculatorProcessTree

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree
All Implemented Interfaces:
Configurable

@Public @Evolving public abstract class ResourceCalculatorProcessTree extends Configured
Interface class to obtain process resource usage NOTE: This class should not be used by external users, but only by external developers to extend and include their own process-tree implementation, especially for platforms other than Linux and Windows.
  • Field Details

  • Constructor Details

    • ResourceCalculatorProcessTree

      public ResourceCalculatorProcessTree(String root)
      Create process-tree instance with specified root process. Subclass must override this.
      Parameters:
      root - process-tree root-process
  • Method Details

    • initialize

      public void initialize() throws YarnException
      Initialize the object.
      Throws:
      YarnException - Throws an exception on error.
    • updateProcessTree

      public abstract void updateProcessTree()
      Update the process-tree with latest state. Each call to this function should increment the age of the running processes that already exist in the process tree. Age is used other API's of the interface.
    • getProcessTreeDump

      public abstract String getProcessTreeDump()
      Get a dump of the process-tree.
      Returns:
      a string concatenating the dump of information of all the processes in the process-tree
    • getVirtualMemorySize

      public long getVirtualMemorySize()
      Get the virtual memory used by all the processes in the process-tree.
      Returns:
      virtual memory used by the process-tree in bytes, UNAVAILABLE if it cannot be calculated.
    • getRssMemorySize

      public long getRssMemorySize()
      Get the resident set size (rss) memory used by all the processes in the process-tree.
      Returns:
      rss memory used by the process-tree in bytes, UNAVAILABLE if it cannot be calculated.
    • getVirtualMemorySize

      public 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.
      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, UNAVAILABLE if it cannot be calculated.
    • getRssMemorySize

      public 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.
      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, UNAVAILABLE if it cannot be calculated.
    • getCumulativeCpuTime

      public long getCumulativeCpuTime()
      Get the CPU time in millisecond used by all the processes in the process-tree since the process-tree was created
      Returns:
      cumulative CPU time in millisecond since the process-tree created, UNAVAILABLE if it cannot be calculated.
    • getCpuUsagePercent

      public float getCpuUsagePercent()
      Get the CPU usage by all the processes in the process-tree based on average between samples as a ratio of overall CPU cycles similar to top. Thus, if 2 out of 4 cores are used this should return 200.0. Note: UNAVAILABLE will be returned in case when CPU usage is not available. It is NOT advised to return any other error code.
      Returns:
      percentage CPU usage since the process-tree was created, UNAVAILABLE if CPU usage cannot be calculated or not available.
    • checkPidPgrpidForMatch

      public abstract boolean checkPidPgrpidForMatch()
      Verify that the tree process id is same as its process group id.
      Returns:
      true if the process id matches else return false.
    • getResourceCalculatorProcessTree

      public static ResourceCalculatorProcessTree getResourceCalculatorProcessTree(String pid, Class<? extends ResourceCalculatorProcessTree> clazz, Configuration conf)
      Create the ResourceCalculatorProcessTree rooted to specified process from the class name and configure it. If class name is null, this method will try and return a process tree plugin available for this system.
      Parameters:
      pid - process pid of the root of the process tree
      clazz - class-name
      conf - configure the plugin with this.
      Returns:
      ResourceCalculatorProcessTree or null if ResourceCalculatorPluginTree is not available for this system.