Class CpuTimeTracker

java.lang.Object
org.apache.hadoop.util.CpuTimeTracker

@Private @Unstable public class CpuTimeTracker extends Object
Utility for sampling and computing CPU usage.
  • Field Details

  • Constructor Details

    • CpuTimeTracker

      public CpuTimeTracker(long jiffyLengthInMillis)
  • Method Details

    • getCpuTrackerUsagePercent

      public float getCpuTrackerUsagePercent()
      Return percentage of cpu time spent over the time since last update. CPU time spent is based on elapsed jiffies multiplied by amount of time for 1 core. Thus, if you use 2 cores completely you would have spent twice the actual time between updates and this will return 200%.
      Returns:
      Return percentage of cpu usage since last update, UNAVAILABLE if there haven't been 2 updates more than minimumTimeInterval apart
    • getCumulativeCpuTime

      public long getCumulativeCpuTime()
      Obtain the cumulative CPU time since the system is on.
      Returns:
      cumulative CPU time in milliseconds
    • updateElapsedJiffies

      public void updateElapsedJiffies(BigInteger elapsedJiffies, long newTime)
      Apply delta to accumulators.
      Parameters:
      elapsedJiffies - updated jiffies
      newTime - new sample time
    • toString

      public String toString()
      Overrides:
      toString in class Object