Class Counter


  • public class Counter
    extends Handle
    A single integer value which can be incremented.
    Author:
    Steinar Knutsen
    • Constructor Summary

      Constructors 
      Constructor Description
      Counter​(java.lang.String name, Statistics manager, boolean fetchParametersFromConfig)
      A monotonically increasing 64 bit integer value.
      Counter​(java.lang.String name, Statistics manager, boolean fetchParametersFromConfig, Callback callback, boolean resetCounter)
      A monotonically increasing 64 bit integer value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      long get()  
      boolean getResetCounter()
      The reset counter is true if this is counter is reset to 0 between each logging interval.
      int hashCode()  
      void increment()
      Increment by 1.
      void increment​(long n)
      Increment by n.
      void reset()
      If this counter should be set to 0 between each logging interval, do that.
      void runHandle()
      Log current state and reset.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Counter

        public Counter​(java.lang.String name,
                       Statistics manager,
                       boolean fetchParametersFromConfig)
        A monotonically increasing 64 bit integer value.
        Parameters:
        name - The name of this counter, for use in logging.
        manager - the statistics manager acquired by injection
        fetchParametersFromConfig - Whether or not this counter should be initialized from config.
      • Counter

        public Counter​(java.lang.String name,
                       Statistics manager,
                       boolean fetchParametersFromConfig,
                       Callback callback,
                       boolean resetCounter)
        A monotonically increasing 64 bit integer value.
        Parameters:
        name - The name of this counter, for use in logging.
        manager - the statistics manager acquired by injection
        fetchParametersFromConfig - Whether or not this counter should be initialized from config.
        callback - will be invoked each time this counter is written to the log
        resetCounter - Control for if this Counter should be reset between each logging interval.
    • Method Detail

      • increment

        public void increment()
        Increment by 1.
      • increment

        public void increment​(long n)
        Increment by n.
      • get

        public long get()
        Returns:
        current value of this counter
      • getResetCounter

        public boolean getResetCounter()
        The reset counter is true if this is counter is reset to 0 between each logging interval.
        Returns:
        whether this counter is reset between each logging interval.
      • reset

        public void reset()
        If this counter should be set to 0 between each logging interval, do that.
      • runHandle

        public void runHandle()
        Log current state and reset.
        Specified by:
        runHandle in class Handle
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in class Handle
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in class Handle