Class SysInfoLinux

java.lang.Object
org.apache.hadoop.util.SysInfo
org.apache.hadoop.util.SysInfoLinux

@Private @Evolving public class SysInfoLinux extends SysInfo
Plugin to calculate resource information on Linux systems.
  • 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/meminfo
      procfsCpuFile - fake file for /proc/cpuinfo
      procfsStatFile - fake file for /proc/stat
      procfsNetFile - fake file for /proc/net/dev
      procfsDisksFile - fake file for /proc/diskstats
      jiffyLengthInMillis - fake jiffy length value
  • Method Details

    • getPhysicalMemorySize

      public long getPhysicalMemorySize()
      Obtain the total size of the physical memory present in the system.
      Specified by:
      getPhysicalMemorySize in class SysInfo
      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 SysInfo
      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 SysInfo
      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 SysInfo
      Returns:
      available virtual memory size in bytes.
    • getNumProcessors

      public int getNumProcessors()
      Obtain the total number of logical processors present on the system.
      Specified by:
      getNumProcessors in class SysInfo
      Returns:
      number of logical processors
    • getNumCores

      public int getNumCores()
      Obtain total number of physical cores present on the system.
      Specified by:
      getNumCores in class SysInfo
      Returns:
      number of physical cores
    • getCpuFrequency

      public long getCpuFrequency()
      Obtain the CPU frequency of on the system.
      Specified by:
      getCpuFrequency in class SysInfo
      Returns:
      CPU frequency in kHz
    • getCumulativeCpuTime

      public long getCumulativeCpuTime()
      Obtain the cumulative CPU time since the system is on.
      Specified by:
      getCumulativeCpuTime in class SysInfo
      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:
      getCpuUsagePercentage in class SysInfo
      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:
      getNumVCoresUsed in class SysInfo
      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:
      getNetworkBytesRead in class SysInfo
      Returns:
      total number of bytes read.
    • getNetworkBytesWritten

      public long getNetworkBytesWritten()
      Obtain the aggregated number of bytes written to the network.
      Specified by:
      getNetworkBytesWritten in class SysInfo
      Returns:
      total number of bytes written.
    • getStorageBytesRead

      public long getStorageBytesRead()
      Description copied from class: SysInfo
      Obtain the aggregated number of bytes read from disks.
      Specified by:
      getStorageBytesRead in class SysInfo
      Returns:
      total number of bytes read.
    • getStorageBytesWritten

      public long getStorageBytesWritten()
      Description copied from class: SysInfo
      Obtain the aggregated number of bytes written to disks.
      Specified by:
      getStorageBytesWritten in class SysInfo
      Returns:
      total number of bytes written.
    • main

      public static void main(String[] args)
      Test the SysInfoLinux.
      Parameters:
      args - - arguments to this calculator test
    • getJiffyLengthInMillis

      public long getJiffyLengthInMillis()