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
A Proc file-system based ProcessTree. Works only on Linux.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final intstatic final longstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree
UNAVAILABLE -
Constructor Summary
ConstructorsConstructorDescriptionProcfsBasedProcessTree(String pid, String procfsDir) ProcfsBasedProcessTree(String pid, String procfsDir, Clock clock) Build a new process tree rooted at the pid. -
Method Summary
Modifier and TypeMethodDescriptionbooleanVerify that the given process id is same as its process group id.static booleancheckPidPgrpidForMatch(String _pid, String procfs) booleanReturns boolean indicating whether pid is in process tree.floatGet the CPU usage by all the processes in the process-tree in Unix.longGet the CPU time in millisecond used by all the processes in the process-tree since the process-tree was createdGet a dump of 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.longgetVirtualMemorySize(int olderThanAge) Get the virtual memory used by all the processes in the process-tree that are older than the passed in age.static booleanChecks if the ProcfsBasedProcessTree is available on this system.static voidTest theProcfsBasedProcessTree.voidsetConf(org.apache.hadoop.conf.Configuration conf) toString()Returns a string printing PIDs of process present in the ProcfsBasedProcessTree.voidUpdate process-tree with latest state.Methods inherited from class org.apache.hadoop.yarn.util.ResourceCalculatorProcessTree
getResourceCalculatorProcessTree, getRssMemorySize, getVirtualMemorySize, initializeMethods inherited from class org.apache.hadoop.conf.Configured
getConf
-
Field Details
-
PROCFS_STAT_FILE
- See Also:
-
PROCFS_CMDLINE_FILE
- See Also:
-
PAGE_SIZE
public static final long PAGE_SIZE -
JIFFY_LENGTH_IN_MILLIS
public static final long JIFFY_LENGTH_IN_MILLIS -
SMAPS
- See Also:
-
KB_TO_BYTES
public static final int KB_TO_BYTES- See Also:
-
processSMAPTree
-
processTree
-
-
Constructor Details
-
ProcfsBasedProcessTree
-
ProcfsBasedProcessTree
-
ProcfsBasedProcessTree
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 treeprocfsDir- 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:
setConfin interfaceorg.apache.hadoop.conf.Configurable- Overrides:
setConfin classorg.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:
updateProcessTreein classResourceCalculatorProcessTree
-
checkPidPgrpidForMatch
public boolean checkPidPgrpidForMatch()Verify that the given process id is same as its process group id.- Specified by:
checkPidPgrpidForMatchin classResourceCalculatorProcessTree- Returns:
- true if the process id matches else return false.
-
checkPidPgrpidForMatch
-
getCurrentProcessIDs
-
getProcessTreeDump
Get a dump of the process-tree.- Specified by:
getProcessTreeDumpin classResourceCalculatorProcessTree- 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:ResourceCalculatorProcessTreeGet the virtual memory used by all the processes in the process-tree that are older than the passed in age.- Overrides:
getVirtualMemorySizein classResourceCalculatorProcessTree- 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.UNAVAILABLEif it cannot be calculated.
-
getRssMemorySize
public long getRssMemorySize(int olderThanAge) Description copied from class:ResourceCalculatorProcessTreeGet the resident set size (rss) memory used by all the processes in the process-tree that are older than the passed in age.- Overrides:
getRssMemorySizein classResourceCalculatorProcessTree- 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.UNAVAILABLEif it cannot be calculated.
-
getCumulativeCpuTime
public long getCumulativeCpuTime()Description copied from class:ResourceCalculatorProcessTreeGet the CPU time in millisecond used by all the processes in the process-tree since the process-tree was created- Overrides:
getCumulativeCpuTimein classResourceCalculatorProcessTree- Returns:
- cumulative CPU time in millisecond since the process-tree
created,
ResourceCalculatorProcessTree.UNAVAILABLEif 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:
getCpuUsagePercentin classResourceCalculatorProcessTree- Returns:
- percentage CPU usage since the process-tree was created,
ResourceCalculatorProcessTree.UNAVAILABLEif CPU usage cannot be calculated or not available.
-
toString
Returns a string printing PIDs of process present in the ProcfsBasedProcessTree. Output format : [pid pid ..] -
contains
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
Test theProcfsBasedProcessTree.- Parameters:
args- the pid arg.
-