java.lang.Object
com.pervasive.datarush.monitoring.BasicCounter
- All Implemented Interfaces:
CounterSupplier,StatisticSupplier
Basic mutable implementation of
CounterSupplier. Counters must be
started before they are first incremented. Once they have stopped they cannot
be started again.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonggetCount()This will return the value of the counter or an undefined value if never started.getState()Returns the current state of the supplier.voidIncrements the counter by1voidincrement(long stepSize) Increments the counter by the specified step sizesnapshot()Returns a snapshot of this statistic.voidstart()Places the counter in theStatisticState.ACTIVE.voidstop()Places the counter in the stopped state.
-
Constructor Details
-
BasicCounter
public BasicCounter()Creates a counter with an initial count of 0. Prior to callingincrement()for the first time,start()must be called.
-
-
Method Details
-
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
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
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.
-