- java.lang.Object
-
- com.pervasive.datarush.monitoring.BasicCounter
-
- All Implemented Interfaces:
CounterSupplier,StatisticSupplier
public final class BasicCounter extends Object implements CounterSupplier
Basic mutable implementation ofCounterSupplier. Counters must be started before they are first incremented. Once they have stopped they cannot be started again.
-
-
Constructor Summary
Constructors Constructor Description BasicCounter()Creates a counter with an initial count of 0.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()This will return the value of the counter or an undefined value if never started.StatisticStategetState()Returns the current state of the supplier.voidincrement()Increments the counter by1voidincrement(long stepSize)Increments the counter by the specified step sizeCounterSuppliersnapshot()Returns a snapshot of this statistic.voidstart()Places the counter in theStatisticState.ACTIVE.voidstop()Places the counter in the stopped state.
-
-
-
Constructor Detail
-
BasicCounter
public BasicCounter()
Creates a counter with an initial count of 0. Prior to callingincrement()for the first time,start()must be called.
-
-
Method Detail
-
start
public void start()
Places the counter in theStatisticState.ACTIVE.- Throws:
IllegalStateException- if the counter is already started or has finished
-
stop
public void stop()
Places the counter in the stopped state. This method can be called while in any state and thus is safe to call within afinallyblock.
-
getState
public StatisticState getState()
Description copied from interface:StatisticSupplierReturns the current state of the supplier.- Specified by:
getStatein interfaceStatisticSupplier- Returns:
- the state of the supplier
-
increment
public void increment()
Increments the counter by1
-
increment
public void increment(long stepSize)
Increments the counter by the specified step size- Parameters:
stepSize- the amount by which to increment
-
snapshot
public CounterSupplier snapshot()
Description copied from interface:StatisticSupplierReturns a snapshot of this statistic.- Specified by:
snapshotin interfaceCounterSupplier- Specified by:
snapshotin interfaceStatisticSupplier- Returns:
- a snapshot of this statistic.
-
getCount
public long getCount()
Description copied from interface:CounterSupplierThis will return the value of the counter or an undefined value if never started.- Specified by:
getCountin interfaceCounterSupplier- Returns:
- the value of the counter or an undefined value if never started.
-
-