Class LinuxInfoUtils

java.lang.Object
org.apache.pulsar.broker.loadbalance.LinuxInfoUtils

public class LinuxInfoUtils extends Object
  • Constructor Details

    • LinuxInfoUtils

      public LinuxInfoUtils()
  • Method Details

    • isLinux

      public static boolean isLinux()
      Determine whether the OS is the linux kernel.
      Returns:
      Whether the OS is the linux kernel
    • isCGroupEnabled

      public static boolean isCGroupEnabled()
      Determine whether the OS enable CG Group.
    • getTotalCpuLimit

      public static double getTotalCpuLimit(boolean isCGroupsEnabled)
      Get total cpu limit.
      Parameters:
      isCGroupsEnabled - Whether CGroup is enabled
      Returns:
      Total cpu limit
    • getCpuUsageForCGroup

      public static double getCpuUsageForCGroup()
      Get CGroup cpu usage.
      Returns:
      Cpu usage
    • getCpuUsageForEntireHost

      public static LinuxInfoUtils.ResourceUsage getCpuUsageForEntireHost()
      Reads first line of /proc/stat to get total cpu usage.
           cpu  user   nice system idle    iowait irq softirq steal guest guest_nice
           cpu  317808 128  58637  2503692 7634   0   13472   0     0     0
       

      Line is split in "words", filtering the first. The sum of all numbers give the amount of cpu cycles used this far. Real CPU usage should equal the sum substracting the idle cycles, this would include iowait, irq and steal.

    • getTotalNicLimit

      public static double getTotalNicLimit(List<String> nics, org.apache.pulsar.broker.BitRateUnit bitRateUnit)
      Get all physical nic limit.
      Parameters:
      nics - All nic path
      bitRateUnit - Bit rate unit
      Returns:
      Total nic limit
    • getTotalNicUsage

      public static double getTotalNicUsage(List<String> nics, LinuxInfoUtils.NICUsageType type, org.apache.pulsar.broker.BitRateUnit bitRateUnit)
      Get all physical nic usage.
      Parameters:
      nics - All nic path
      type - Nic's usage type: transport, receive
      bitRateUnit - Bit rate unit
      Returns:
      Total nic usage
    • getUsablePhysicalNICs

      public static List<String> getUsablePhysicalNICs()
      Get paths of all usable physical nic.
      Returns:
      All usable physical nic paths.
    • checkHasNicSpeeds

      public static boolean checkHasNicSpeeds()
      Check this VM has nic speed.
      Returns:
      Whether the VM has nic speed