Class EventsCollector<E extends Enum<E>>
- java.lang.Object
-
- org.pipecraft.infra.monitoring.collectors.EventsCollector<E>
-
- All Implemented Interfaces:
JsonMonitorable
public class EventsCollector<E extends Enum<E>> extends Object implements JsonMonitorable
Counts events that fall into one of a predefined set of categories. Snapshots aren't guaranteed to be consistent.- Author:
- Eyal Schneider
-
-
Constructor Summary
Constructors Constructor Description EventsCollector(Class<E> categoriesEnumClass)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all counters.voidcountEvent(E category)Indicates that an event of a given category just occurred.EventStatsMap<E>getAll()Map<String,JsonMonitorable>getChildren()longgetCount(E category)net.minidev.json.JSONObjectgetOwnMetrics()-
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
-
-
-
-
Method Detail
-
countEvent
public void countEvent(E category)
Indicates that an event of a given category just occurred.- Parameters:
category- The category of the event
-
getCount
public long getCount(E category)
- Parameters:
category- A category- Returns:
- The number of events that have been counted in the given category
-
getAll
public EventStatsMap<E> getAll()
- Returns:
- A snapshot of the event counts map. Not necessarily consistent.
-
clear
public void clear()
Clears all counters. Not guaranteed to run atomically.
-
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.
-
-