Class EventSampler

java.lang.Object
com.apple.foundationdb.relational.util.EventSampler
All Implemented Interfaces:
Sampler

@API(EXPERIMENTAL) public class EventSampler extends Object implements Sampler
A Sampler which will aim for a long-term stable throughput at or less than a certain fraction of events (instead of per unit time).

This sampler will compute whether an item can be sampled based on a number of events, rather than as a function of time, so the long-term throughput is measured in samples/event. Event sampling is useful when you have a consistent steady-state of incoming events, and you just want to take a limited sample of those events, but don't care about shaping those events at all (e.g. you don't want to allow bursty traffic or anything like that). This is mainly because the way EventSampling tracks time is by the passage of events, so it will only ever allow through samples as a fraction of events, no matter how irregular in time those events may be. If you are interested in a sampling method that captures time-irregular traffic patterns, then you should be sampling according to time-rates, rather than even rates.

  • Constructor Details

    • EventSampler

      public EventSampler(int maxSamplesPerEvent, long refreshIntervalEvents)
  • Method Details

    • canSample

      public boolean canSample()
      Description copied from interface: Sampler
      Determine if an element can be sampled.
      Specified by:
      canSample in interface Sampler
      Returns:
      true if an element can be sampled, false otherwise.