Class LongAdderCounter

java.lang.Object
org.apache.bookkeeper.stats.prometheus.LongAdderCounter
All Implemented Interfaces:
Counter

public class LongAdderCounter extends 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 Details

  • Method Details

    • 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
    • addLatency

      public void addLatency(long eventLatency, TimeUnit unit)
      When counter is used to count time. consistent with the DataSketchesOpStatsLogger.registerSuccessfulEvent(long, TimeUnit) 's logic
      Specified by:
      addLatency in interface Counter
      Parameters:
      eventLatency - The event latency
    • get

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

      public Map<String,String> getLabels()
    • isThreadInitialized

      public boolean isThreadInitialized()
    • initializeThread

      public void initializeThread(Map<String,String> labels)