org.apache.hadoop.util
Class ProcfsBasedProcessTree

java.lang.Object
  extended by org.apache.hadoop.util.ProcfsBasedProcessTree

public class ProcfsBasedProcessTree
extends Object

A Proc file-system based ProcessTree. Works only on Linux.


Field Summary
static long DEFAULT_SLEEPTIME_BEFORE_SIGKILL
           
 
Constructor Summary
ProcfsBasedProcessTree(String pid)
           
ProcfsBasedProcessTree(String pid, String procfsDir)
           
 
Method Summary
 void destroy()
          Destroy the process-tree.
 long getCumulativeVmem()
          Get the cumulative virtual memory used by all the processes in the process-tree.
 long getCumulativeVmem(int olderThanAge)
          Get the cumulative virtual memory used by all the processes in the process-tree that are older than the passed in age.
static String getPidFromPidFile(String pidFileName)
          Get PID from a pid-file.
 ProcfsBasedProcessTree getProcessTree()
          Get the process-tree with latest state.
 boolean isAlive()
          Is the process-tree alive? Currently we care only about the status of the root-process.
static boolean isAvailable()
          Checks if the ProcfsBasedProcessTree is available on this system.
 void setSigKillInterval(long interval)
           
 String toString()
          Returns a string printing PIDs of process present in the ProcfsBasedProcessTree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SLEEPTIME_BEFORE_SIGKILL

public static final long DEFAULT_SLEEPTIME_BEFORE_SIGKILL
See Also:
Constant Field Values
Constructor Detail

ProcfsBasedProcessTree

public ProcfsBasedProcessTree(String pid)

ProcfsBasedProcessTree

public ProcfsBasedProcessTree(String pid,
                              String procfsDir)
Method Detail

setSigKillInterval

public void setSigKillInterval(long interval)

isAvailable

public static boolean isAvailable()
Checks if the ProcfsBasedProcessTree is available on this system.

Returns:
true if ProcfsBasedProcessTree is available. False otherwise.

getProcessTree

public ProcfsBasedProcessTree getProcessTree()
Get the process-tree with latest state. If the root-process is not alive, an empty tree will be returned.

Returns:
the process-tree with latest state.

isAlive

public boolean isAlive()
Is the process-tree alive? Currently we care only about the status of the root-process.

Returns:
true if the process-true is alive, false otherwise.

destroy

public void destroy()
Destroy the process-tree. Currently we only make sure the root process is gone. It is the responsibility of the root process to make sure that all its descendants are cleaned up.


getCumulativeVmem

public long getCumulativeVmem()
Get the cumulative virtual memory used by all the processes in the process-tree.

Returns:
cumulative virtual memory used by the process-tree in bytes.

getCumulativeVmem

public long getCumulativeVmem(int olderThanAge)
Get the cumulative 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:
cumulative virtual memory used by the process-tree in bytes, for processes older than this age.

getPidFromPidFile

public static String getPidFromPidFile(String pidFileName)
Get PID from a pid-file.

Parameters:
pidFileName - Name of the pid-file.
Returns:
the PID string read from the pid-file. Returns null if the pidFileName points to a non-existing file or if read fails from the file.

toString

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

Overrides:
toString in class Object


Copyright © 2009 The Apache Software Foundation