java.lang.Object
com.northconcepts.datapipeline.meter.Meter
Direct Known Subclasses:
RecordMeter

public class Meter extends Object
Counts units (such as bytes or records) and reports their average rate per second since the meter was created or last reset.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
    static final long
     
    static final long
     
    static final long
     
    static final long
     
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add()
    Adds one unit to the count.
    add(long difference)
    Adds the given number of units to the count.
    Adds this meter's count and timer state to the given exception and returns it.
    long
     
    long
    Returns the milliseconds elapsed since the meter was created or last reset, up to when its timer was stopped (at least 1).
    long
    Returns the time (milliseconds since the epoch) the meter was created or last reset.
    double
    Returns units per second.
    Returns the rate as a human readable string scaled by powers of 1000, such as 12.5 kilo-units/s.
    Returns the rate as a human readable string using the given unit name (units if null), such as 12.5 kilo-bytes/s.
    boolean
    Indicates if the timer is still running (not stopped since the meter was created or last reset).
    restarts the timer and count.
    Stops the timer so the elapsed time no longer grows; later calls have no effect until reset().
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Meter

      public Meter()
  • Method Details

    • reset

      public Meter reset()
      restarts the timer and count.
    • stopTimer

      public Meter stopTimer()
      Stops the timer so the elapsed time no longer grows; later calls have no effect until reset().
    • isRunning

      public boolean isRunning()
      Indicates if the timer is still running (not stopped since the meter was created or last reset).
    • add

      public void add()
      Adds one unit to the count.
    • add

      public Meter add(long difference)
      Adds the given number of units to the count.
    • getCount

      public long getCount()
    • getStarted

      public long getStarted()
      Returns the time (milliseconds since the epoch) the meter was created or last reset.
    • getElapsedTime

      public long getElapsedTime()
      Returns the milliseconds elapsed since the meter was created or last reset, up to when its timer was stopped (at least 1).
    • getUnitsPerSecond

      public double getUnitsPerSecond()
      Returns units per second. A value less than zero (0) means the rate is undefined due to integer overflow and needs to be reset.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUnitsPerSecondAsString

      public String getUnitsPerSecondAsString()
      Returns the rate as a human readable string scaled by powers of 1000, such as 12.5 kilo-units/s.
    • getUnitsPerSecondAsString

      public String getUnitsPerSecondAsString(String units)
      Returns the rate as a human readable string using the given unit name (units if null), such as 12.5 kilo-bytes/s.
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Adds this meter's count and timer state to the given exception and returns it.