Class Sampler<T>

java.lang.Object
org.apache.cassandra.metrics.Sampler<T>
Direct Known Subclasses:
FrequencySampler, MaxSampler

public abstract class Sampler<T> extends Object
  • Field Details

    • samplerExecutor

      public static final ExecutorPlus samplerExecutor
  • Constructor Details

    • Sampler

      public Sampler()
  • Method Details

    • addSample

      public void addSample(T item, int value)
    • insert

      protected abstract void insert(T item, long value)
    • isEnabled

      public boolean isEnabled()
      A sampler is enabled between {@link this#beginSampling} and {@link this#finishSampling}
      Returns:
      true if the sampler is enabled.
    • disable

      public void disable()
    • isActive

      public boolean isActive()
      Returns:
      true if the sampler is active. A sampler is active only if it is enabled and the current time is within the `durationMillis` when beginning sampling.
    • updateEndTime

      public void updateEndTime(long endTimeMillis)
      Update the end time for the sampler. Implicitly, calling this method enables the sampler.
    • beginSampling

      public abstract void beginSampling(int capacity, long durationMillis)
      Begin sampling with the configured capacity and duration
      Parameters:
      capacity - Number of sample items to keep in memory, the lower this is the less accurate results are. For best results use value close to cardinality, but understand the memory trade offs.
      durationMillis - Upperbound duration in milliseconds for sampling. The sampler stops accepting new samples after exceeding the duration even if finishSampling(int)} is not called.
    • finishSampling

      public abstract List<Sampler.Sample<T>> finishSampling(int count)
      Stop sampling and return the results
      Parameters:
      count - The number of the samples requested to retrieve from the sampler
      Returns:
      a list of samples, the size is the minimum of the total samples and .
    • toString

      public abstract String toString(T value)
    • shutdownNowAndWait

      public static void shutdownNowAndWait(long time, TimeUnit units) throws InterruptedException, TimeoutException
      Throws:
      InterruptedException
      TimeoutException