Class BlockingSampler<T>
- java.lang.Object
-
- org.pipecraft.infra.monitoring.sampling.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 Summary
Constructors Constructor Description BlockingSampler(int size)ConstructorBlockingSampler(int size, SampleTextualizer<T> textualizer)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,JsonMonitorable>getChildren()net.minidev.json.JSONObjectgetOwnMetrics()Collection<T>getSnapshot()booleannewValue(T value)Notifies about a new valueintsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pipecraft.infra.monitoring.JsonMonitorable
getFullMetrics
-
-
-
-
Constructor Detail
-
BlockingSampler
public BlockingSampler(int size, SampleTextualizer<T> textualizer)Constructor- Parameters:
size- The number of sampled values to keeptextualizer- 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
-
getSnapshot
public Collection<T> getSnapshot()
- Specified by:
getSnapshotin interfaceSampler<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:
getOwnMetricsin interfaceJsonMonitorable- Returns:
- The json string describing the entity, not including the child entities.
-
getChildren
public Map<String,JsonMonitorable> getChildren()
- Specified by:
getChildrenin interfaceJsonMonitorable- 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.
-
-