Class BlockingSampler<T>

  • Type Parameters:
    T - The type of the values to be sampled.
    All Implemented Interfaces:
    JsonMonitorable, Sampler<T>

    public class BlockingSampler<T>
    extends Object
    implements Sampler<T>
    A utility for sampling of recent values, using a blocking approach for guaranteeing k latest events in a FIFO order.
    Author:
    Eyal Schneider
    • Constructor Detail

      • BlockingSampler

        public BlockingSampler​(int size,
                               SampleTextualizer<T> textualizer)
        Constructor
        Parameters:
        size - The number of sampled values to keep
        textualizer - The textualizer to use for converting sample items into text for monitoring purposes
      • BlockingSampler

        public BlockingSampler​(int size)
        Constructor
        Parameters:
        size - The number of sampled values to keep
    • Method Detail

      • newValue

        public boolean newValue​(T value)
        Notifies about a new value
        Specified by:
        newValue in interface Sampler<T>
        Parameters:
        value - The new value.
        Returns:
        true iff the new value has been recorded in the sample.
      • getSnapshot

        public Collection<T> getSnapshot()
        Specified by:
        getSnapshot in interface Sampler<T>
        Returns:
        The collection of all values currently stored in the sampler. The collection is ordered from latest even to oldest, and no event in this range is skipped.
      • getOwnMetrics

        public net.minidev.json.JSONObject getOwnMetrics()
        Specified by:
        getOwnMetrics in interface JsonMonitorable
        Returns:
        The json string describing the entity, not including the child entities.
      • getChildren

        public Map<String,​JsonMonitorable> getChildren()
        Specified by:
        getChildren in interface JsonMonitorable
        Returns:
        The monitorable children of this entity, as [id, JsonExportable] pairs. Using this method, the framework can manage a complete tree to be monitored, where every entity has a unique path.
      • size

        public int size()
        Specified by:
        size in interface Sampler<T>
        Returns:
        The capacity of the sampler