Class Meter
java.lang.Object
com.northconcepts.datapipeline.meter.Meter
- Direct Known Subclasses:
RecordMeter
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd()Adds one unit to the count.add(long difference) Adds the given number of units to the count.addExceptionProperties(DataException exception) Adds this meter's count and timer state to the given exception and returns it.longgetCount()longReturns the milliseconds elapsed since the meter was created or last reset, up to when its timer was stopped (at least 1).longReturns the time (milliseconds since the epoch) the meter was created or last reset.doubleReturns units per second.Returns the rate as a human readable string scaled by powers of 1000, such as12.5 kilo-units/s.getUnitsPerSecondAsString(String units) Returns the rate as a human readable string using the given unit name (unitsif null), such as12.5 kilo-bytes/s.booleanIndicates if the timer is still running (not stopped since the meter was created or last reset).reset()restarts the timer and count.Stops the timer so the elapsed time no longer grows; later calls have no effect untilreset().toString()
-
Field Details
-
K
public static final long K- See Also:
-
M
public static final long M- See Also:
-
G
public static final long G- See Also:
-
T
public static final long T- See Also:
-
P
public static final long P- See Also:
-
E
public static final long E- See Also:
-
-
Constructor Details
-
Meter
public Meter()
-
-
Method Details
-
reset
restarts the timer and count. -
stopTimer
Stops the timer so the elapsed time no longer grows; later calls have no effect untilreset(). -
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
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 bereset.- See Also:
-
toString
-
getUnitsPerSecondAsString
Returns the rate as a human readable string scaled by powers of 1000, such as12.5 kilo-units/s. -
getUnitsPerSecondAsString
Returns the rate as a human readable string using the given unit name (unitsif null), such as12.5 kilo-bytes/s. -
addExceptionProperties
Adds this meter's count and timer state to the given exception and returns it.
-