Class StatisticsMap

java.lang.Object
com.pervasive.datarush.monitoring.StatisticsMap
All Implemented Interfaces:
Serializable

public final class StatisticsMap extends Object implements Serializable
Utility that provides a mapping from StatisticDefinition to StatisticSupplier. This map is backed by a LinkedHashMap so that insertion order is preserved. As values are added to the map, we check that the supplier is of an appropriate type so that on read we then get a type-safe lookup.
See Also:
  • Constructor Details

    • StatisticsMap

      public StatisticsMap()
      Create an empty map.
    • StatisticsMap

      public StatisticsMap(List<RuntimeStatistic<?>> entries)
      Creates a map consisting of the specified entries
      Parameters:
      entries - the list of entries
  • Method Details

    • put

      public <T extends StatisticSupplier> void put(RuntimeStatistic<T> statistic)
      Type-safe put that adds a pair of statistic and definition
      Type Parameters:
      T - the type of supplier
      Parameters:
      statistic - the statistic to add
    • put

      public void put(StatisticDefinition<?> definition, StatisticSupplier supplier)
      Adds a value to the map.
      Parameters:
      definition - the definition.
      supplier - the supplier
      Throws:
      ClassCastException - If the supplier is not of a type appropriate for the definition.
    • get

      public <T extends StatisticSupplier> T get(StatisticDefinition<T> definition)
      Returns the value corresponding to the given definition
      Type Parameters:
      T - the type of supplier that corresponds to the definition.
      Parameters:
      definition - the definition
      Returns:
      the value. will never be null but may be "unavailable"
    • keys

      public Set<StatisticDefinition<?>> keys()
      Returns the set of keys. This will be returned in the order in which the values were added to the map.
      Returns:
      the set of keys
    • entries

      public List<RuntimeStatistic<?>> entries()
      Returns the list of statistic pairs
      Returns:
      the entries in the map
    • size

      public int size()
      Returns the number of entries in the map
      Returns:
      the number of entries in the map
    • finalSnapshot

      public StatisticsMap finalSnapshot()
      Returns a map of all the statistics in this map, converting to final snapshots.
      Returns:
      a final snapshot of this map