Class EventsCollector<E extends Enum<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 Detail

      • EventsCollector

        public EventsCollector​(Class<E> categoriesEnumClass)
        Constructor
        Parameters:
        categoriesEnumClass - the enum describing the different categories to be tracked
    • 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:
        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.