Package org.apache.hadoop.yarn.util
Class ResourceCalculatorProcessTree
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree
- All Implemented Interfaces:
Configurable
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate process-tree instance with specified root process. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanVerify that the tree process id is same as its process group id.floatGet 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.longGet the CPU time in millisecond used by all the processes in the process-tree since the process-tree was createdabstract StringGet a dump of the process-tree.getResourceCalculatorProcessTree(String pid, Class<? extends ResourceCalculatorProcessTree> clazz, Configuration conf) Create the ResourceCalculatorProcessTree rooted to specified process from the class name and configure it.longGet the resident set size (rss) memory used by all the processes in the process-tree.longgetRssMemorySize(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.longGet the virtual memory used by all the processes in the process-tree.longgetVirtualMemorySize(int olderThanAge) Get the virtual memory used by all the processes in the process-tree that are older than the passed in age.voidInitialize the object.abstract voidUpdate the process-tree with latest state.Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
-
Field Details
-
UNAVAILABLE
public static final int UNAVAILABLE- See Also:
-
-
Constructor Details
-
ResourceCalculatorProcessTree
Create process-tree instance with specified root process. Subclass must override this.- Parameters:
root- process-tree root-process
-
-
Method Details
-
initialize
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
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,
UNAVAILABLEif 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,
UNAVAILABLEif 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,
UNAVAILABLEif 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,
UNAVAILABLEif 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,
UNAVAILABLEif 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,
UNAVAILABLEif 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 treeclazz- class-nameconf- configure the plugin with this.- Returns:
- ResourceCalculatorProcessTree or null if ResourceCalculatorPluginTree is not available for this system.
-