Class LongAdderCounter

  • All Implemented Interfaces:
    Counter

    public class LongAdderCounter
    extends java.lang.Object
    implements Counter
    Counter implementation based on LongAdder.

    LongAdder keeps a counter per-thread and then aggregates to get the result, in order to avoid contention between multiple threads.

    • Constructor Summary

      Constructors 
      Constructor Description
      LongAdderCounter​(java.util.Map<java.lang.String,​java.lang.String> labels)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCount​(long delta)
      Add delta to the value associated with this stat.
      void addLatency​(long eventLatency, java.util.concurrent.TimeUnit unit)
      When counter is used to count time.
      void clear()
      Clear this stat.
      void dec()
      Decrement the value associated with this stat.
      java.lang.Long get()
      Get the value associated with this stat.
      java.util.Map<java.lang.String,​java.lang.String> getLabels()  
      void inc()
      Increment the value associated with this stat.
      void initializeThread​(java.util.Map<java.lang.String,​java.lang.String> labels)  
      boolean isThreadInitialized()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LongAdderCounter

        public LongAdderCounter​(java.util.Map<java.lang.String,​java.lang.String> labels)
    • Method Detail

      • clear

        public void clear()
        Description copied from interface: Counter
        Clear this stat.
        Specified by:
        clear in interface Counter
      • inc

        public void inc()
        Description copied from interface: Counter
        Increment the value associated with this stat.
        Specified by:
        inc in interface Counter
      • dec

        public void dec()
        Description copied from interface: Counter
        Decrement the value associated with this stat.
        Specified by:
        dec in interface Counter
      • addCount

        public void addCount​(long delta)
        Description copied from interface: Counter
        Add delta to the value associated with this stat.
        Specified by:
        addCount in interface Counter
      • get

        public java.lang.Long get()
        Description copied from interface: Counter
        Get the value associated with this stat.
        Specified by:
        get in interface Counter
      • getLabels

        public java.util.Map<java.lang.String,​java.lang.String> getLabels()
      • isThreadInitialized

        public boolean isThreadInitialized()
      • initializeThread

        public void initializeThread​(java.util.Map<java.lang.String,​java.lang.String> labels)