Package org.apache.hadoop.util
Class SysInfoLinux
java.lang.Object
org.apache.hadoop.util.SysInfo
org.apache.hadoop.util.SysInfoLinux
Plugin to calculate resource information on Linux systems.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongObtain the total size of the available physical memory present in the system.longObtain the total size of the available virtual memory present in the system.longObtain the CPU frequency of on the system.floatObtain the CPU usage % of the machine.longObtain the cumulative CPU time since the system is on.longlongObtain the aggregated number of bytes read over the network.longObtain the aggregated number of bytes written to the network.intObtain total number of physical cores present on the system.intObtain the total number of logical processors present on the system.floatObtain the number of VCores used.longObtain the total size of the physical memory present in the system.longObtain the aggregated number of bytes read from disks.longObtain the aggregated number of bytes written to disks.longObtain the total size of the virtual memory present in the system.static voidTest theSysInfoLinux.Methods inherited from class org.apache.hadoop.util.SysInfo
newInstance
-
Field Details
-
PAGE_SIZE
public static final long PAGE_SIZE -
JIFFY_LENGTH_IN_MILLIS
public static final long JIFFY_LENGTH_IN_MILLIS
-
-
Constructor Details
-
SysInfoLinux
public SysInfoLinux() -
SysInfoLinux
@VisibleForTesting public SysInfoLinux(String procfsMemFile, String procfsCpuFile, String procfsStatFile, String procfsNetFile, String procfsDisksFile, long jiffyLengthInMillis) Constructor which allows assigning the /proc/ directories. This will be used only in unit tests.- Parameters:
procfsMemFile- fake file for /proc/meminfoprocfsCpuFile- fake file for /proc/cpuinfoprocfsStatFile- fake file for /proc/statprocfsNetFile- fake file for /proc/net/devprocfsDisksFile- fake file for /proc/diskstatsjiffyLengthInMillis- fake jiffy length value
-
-
Method Details
-
getPhysicalMemorySize
public long getPhysicalMemorySize()Obtain the total size of the physical memory present in the system.- Specified by:
getPhysicalMemorySizein classSysInfo- Returns:
- physical memory size bytes.
-
getVirtualMemorySize
public long getVirtualMemorySize()Obtain the total size of the virtual memory present in the system.- Specified by:
getVirtualMemorySizein classSysInfo- 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:
getAvailablePhysicalMemorySizein classSysInfo- 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:
getAvailableVirtualMemorySizein classSysInfo- Returns:
- available virtual memory size in bytes.
-
getNumProcessors
public int getNumProcessors()Obtain the total number of logical processors present on the system.- Specified by:
getNumProcessorsin classSysInfo- Returns:
- number of logical processors
-
getNumCores
public int getNumCores()Obtain total number of physical cores present on the system.- Specified by:
getNumCoresin classSysInfo- Returns:
- number of physical cores
-
getCpuFrequency
public long getCpuFrequency()Obtain the CPU frequency of on the system.- Specified by:
getCpuFrequencyin classSysInfo- Returns:
- CPU frequency in kHz
-
getCumulativeCpuTime
public long getCumulativeCpuTime()Obtain the cumulative CPU time since the system is on.- Specified by:
getCumulativeCpuTimein classSysInfo- Returns:
- cumulative CPU time in milliseconds
-
getCpuUsagePercentage
public float getCpuUsagePercentage()Obtain the CPU usage % of the machine. Return -1 if it is unavailable- Specified by:
getCpuUsagePercentagein classSysInfo- Returns:
- CPU usage as a percentage (from 0 to 100) of available cycles.
-
getNumVCoresUsed
public float getNumVCoresUsed()Obtain the number of VCores used. Return -1 if it is unavailable- Specified by:
getNumVCoresUsedin classSysInfo- Returns:
- Number of VCores used a percentage (from 0 to #VCores).
-
getNetworkBytesRead
public long getNetworkBytesRead()Obtain the aggregated number of bytes read over the network.- Specified by:
getNetworkBytesReadin classSysInfo- Returns:
- total number of bytes read.
-
getNetworkBytesWritten
public long getNetworkBytesWritten()Obtain the aggregated number of bytes written to the network.- Specified by:
getNetworkBytesWrittenin classSysInfo- Returns:
- total number of bytes written.
-
getStorageBytesRead
public long getStorageBytesRead()Description copied from class:SysInfoObtain the aggregated number of bytes read from disks.- Specified by:
getStorageBytesReadin classSysInfo- Returns:
- total number of bytes read.
-
getStorageBytesWritten
public long getStorageBytesWritten()Description copied from class:SysInfoObtain the aggregated number of bytes written to disks.- Specified by:
getStorageBytesWrittenin classSysInfo- Returns:
- total number of bytes written.
-
main
Test theSysInfoLinux.- Parameters:
args- - arguments to this calculator test
-
getJiffyLengthInMillis
public long getJiffyLengthInMillis()
-