Class BasicCounter

java.lang.Object
com.pervasive.datarush.monitoring.BasicCounter
All Implemented Interfaces:
CounterSupplier, StatisticSupplier

public final class BasicCounter extends Object implements CounterSupplier
Basic mutable implementation of CounterSupplier. Counters must be started before they are first incremented. Once they have stopped they cannot be started again.
  • Constructor Details

    • BasicCounter

      public BasicCounter()
      Creates a counter with an initial count of 0. Prior to calling increment() for the first time, start() must be called.
  • Method Details

    • start

      public void start()
      Places the counter in the StatisticState.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 a finally block.
    • getState

      public StatisticState getState()
      Description copied from interface: StatisticSupplier
      Returns the current state of the supplier.
      Specified by:
      getState in interface StatisticSupplier
      Returns:
      the state of the supplier
    • increment

      public void increment()
      Increments the counter by 1
    • 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: StatisticSupplier
      Returns a snapshot of this statistic.
      Specified by:
      snapshot in interface CounterSupplier
      Specified by:
      snapshot in interface StatisticSupplier
      Returns:
      a snapshot of this statistic.
    • getCount

      public long getCount()
      Description copied from interface: CounterSupplier
      This will return the value of the counter or an undefined value if never started.
      Specified by:
      getCount in interface CounterSupplier
      Returns:
      the value of the counter or an undefined value if never started.