Class ActionStatsMap<E extends Enum<E>>

  • Type Parameters:
    E - The enum class representing all possible categories that stats are being gathered on
    All Implemented Interfaces:
    JsonMonitorable

    public class ActionStatsMap<E extends Enum<E>>
    extends Object
    implements JsonMonitorable
    A collection of simple statistics gathered on multiple categories. Relevant for actions that have a duration and terminate with some outcome type, belonging to a predefined set of possible types. Not thread safe.
    Author:
    Eyal Schneider
    • Constructor Detail

      • ActionStatsMap

        public ActionStatsMap​(Class<E> enumType)
        Constructor
        Parameters:
        enumType - The type of the enum describing all available categories
    • Method Detail

      • getRunningCount

        public int getRunningCount()
        Returns:
        The number of running actions
      • getTotalCompletedCount

        public int getTotalCompletedCount()
        Returns:
        The total number of completed actions
      • getStats

        public ActionStats getStats​(E category)
        Parameters:
        category - A statistics category
        Returns:
        the category statistics
      • getCategoryStats

        public Map<E,​ActionStats> getCategoryStats()
        Returns:
        the category statistics (read only)
      • setRunningCount

        public void setRunningCount​(int runningCount)
        Parameters:
        runningCount - The number of running actions
      • setCategoryStats

        public void setCategoryStats​(E category,
                                     long completed,
                                     long totalDuration)
        Sets the statistics for a specific category.
        Parameters:
        category - A stats category
        completed - The number of completed actions in the given category
        totalDuration - The total duration, in microseconds, of the completed actions of the given category
      • 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,​? extends 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.