org.apache.hadoop.util
Class LinuxResourceCalculatorPlugin

java.lang.Object
  extended by org.apache.hadoop.conf.Configured
      extended by org.apache.hadoop.util.ResourceCalculatorPlugin
          extended by org.apache.hadoop.util.LinuxResourceCalculatorPlugin
All Implemented Interfaces:
Configurable

public class LinuxResourceCalculatorPlugin
extends ResourceCalculatorPlugin

Plugin to calculate resource information on Linux systems.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.util.ResourceCalculatorPlugin
ResourceCalculatorPlugin.ProcResourceValues
 
Constructor Summary
LinuxResourceCalculatorPlugin()
           
LinuxResourceCalculatorPlugin(String procfsMemFile, String procfsCpuFile, String procfsStatFile, long jiffyLengthInMillis)
          Constructor which allows assigning the /proc/ directories.
 
Method Summary
 long getAvailablePhysicalMemorySize()
          Obtain the total size of the available physical memory present in the system.
 long getAvailableVirtualMemorySize()
          Obtain the total size of the available virtual memory present in the system.
 long getCpuFrequency()
          Obtain the CPU frequency of on the system.
 float getCpuUsage()
          Obtain the CPU usage % of the machine.
 long getCumulativeCpuTime()
          Obtain the cumulative CPU time since the system is on.
 int getNumProcessors()
          Obtain the total number of processors present on the system.
 long getPhysicalMemorySize()
          Obtain the total size of the physical memory present in the system.
 ResourceCalculatorPlugin.ProcResourceValues getProcResourceValues()
          Obtain resource status used by current process tree.
 long getVirtualMemorySize()
          Obtain the total size of the virtual memory present in the system.
static void main(String[] args)
          Test the LinuxResourceCalculatorPlugin
 
Methods inherited from class org.apache.hadoop.util.ResourceCalculatorPlugin
getResourceCalculatorPlugin
 
Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinuxResourceCalculatorPlugin

public LinuxResourceCalculatorPlugin()

LinuxResourceCalculatorPlugin

public LinuxResourceCalculatorPlugin(String procfsMemFile,
                                     String procfsCpuFile,
                                     String procfsStatFile,
                                     long jiffyLengthInMillis)
Constructor which allows assigning the /proc/ directories. This will be used only in unit tests

Parameters:
procfsMemFile - fake file for /proc/meminfo
procfsCpuFile - fake file for /proc/cpuinfo
procfsStatFile - fake file for /proc/stat
jiffyLengthInMillis - fake jiffy length value
Method Detail

getPhysicalMemorySize

public long getPhysicalMemorySize()
Obtain the total size of the physical memory present in the system.

Specified by:
getPhysicalMemorySize in class ResourceCalculatorPlugin
Returns:
physical memory size bytes.

getVirtualMemorySize

public long getVirtualMemorySize()
Obtain the total size of the virtual memory present in the system.

Specified by:
getVirtualMemorySize in class ResourceCalculatorPlugin
Returns:
virtual memory size in bytes.

getAvailablePhysicalMemorySize

public long getAvailablePhysicalMemorySize()
Obtain the total size of the available physical memory present in the system.

Specified by:
getAvailablePhysicalMemorySize in class ResourceCalculatorPlugin
Returns:
available physical memory size bytes.

getAvailableVirtualMemorySize

public long getAvailableVirtualMemorySize()
Obtain the total size of the available virtual memory present in the system.

Specified by:
getAvailableVirtualMemorySize in class ResourceCalculatorPlugin
Returns:
available virtual memory size in bytes.

getNumProcessors

public int getNumProcessors()
Obtain the total number of processors present on the system.

Specified by:
getNumProcessors in class ResourceCalculatorPlugin
Returns:
number of processors

getCpuFrequency

public long getCpuFrequency()
Obtain the CPU frequency of on the system.

Specified by:
getCpuFrequency in class ResourceCalculatorPlugin
Returns:
CPU frequency in kHz

getCumulativeCpuTime

public long getCumulativeCpuTime()
Obtain the cumulative CPU time since the system is on.

Specified by:
getCumulativeCpuTime in class ResourceCalculatorPlugin
Returns:
cumulative CPU time in milliseconds

getCpuUsage

public float getCpuUsage()
Obtain the CPU usage % of the machine. Return -1 if it is unavailable

Specified by:
getCpuUsage in class ResourceCalculatorPlugin
Returns:
CPU usage in %

main

public static void main(String[] args)
Test the LinuxResourceCalculatorPlugin

Parameters:
args -

getProcResourceValues

public ResourceCalculatorPlugin.ProcResourceValues getProcResourceValues()
Description copied from class: ResourceCalculatorPlugin
Obtain resource status used by current process tree.

Specified by:
getProcResourceValues in class ResourceCalculatorPlugin


Copyright © 2009 The Apache Software Foundation