Class DefaultStatisticsData

  • All Implemented Interfaces:
    StatisticsData

    public class DefaultStatisticsData
    extends java.lang.Object
    implements StatisticsData
    Class stores data collected by Collectors in a map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addDataCollector​(java.lang.String name)
      Method adds a new collector with key name.
      void balanceDataLevels​(java.lang.String name)
      Method checks, if ticks held in different levels still observe the defined borders.
      boolean containsDataCollector​(java.lang.String name)
      Find out, whether the Data-Collector identified by name is registered.
      java.lang.Object[][] getAllData​(java.lang.String name, int maxTicks, long utcOffset)
      Get all available data of the Data-Collector defined by name.
      float getCollectorValue​(java.lang.String name, long timestamp)
      Get one value of the collector called name at the given timestamp.
      int getCurrentSize​(java.lang.String name)
      Get the current size of the data-collector called name.
      int[] getLevelSizes​(java.lang.String name)
      Returns the tick-amount in the different level-sizes as int-Array.
      java.lang.Object[][] getTickAsArray​(java.lang.String name, long period, int maxTicks, long utcOffset)
      Get time-period of length period in ms from Collector name as Object Array.
      java.lang.Object[][] getTimePeriodData​(java.lang.String name, long start, long end, long utcOffset)
      Get the data of a speciific period of time from start till end.
      protected void printStats​(java.lang.String name)  
      boolean putData​(java.lang.String name, long timestamp, float value)
      Method for putting one collected dataset consisting of a timestamp and a value.
      boolean removeDataCollector​(java.lang.String name)
      Removes a registered Data-Collector, defined by name.
      void setSizeLvl1Ms​(long ms)
      Setter for the time-period ticks are stored in level-1.
      void setSizeLvl2Ms​(long ms)
      Setter for the time-period, ticks are stored in level-2.
      void setSizeLvl3Ms​(long ms)
      Setter for the time-period, ticks are stored in level-3.
      protected void trimAndAggregate​(java.util.NavigableMap<java.lang.Long,​java.lang.Float> fromMap, java.util.NavigableMap<java.lang.Long,​java.lang.Float> toMap, long now, long millisToKeep, int ticksToRemoveAtOnce)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultStatisticsData

        public DefaultStatisticsData()
    • Method Detail

      • addDataCollector

        public boolean addDataCollector​(java.lang.String name)
        Description copied from interface: StatisticsData
        Method adds a new collector with key name.
        Specified by:
        addDataCollector in interface StatisticsData
        Parameters:
        name - The name of the collector.
        Returns:
        boolean True, if added successfully.
      • removeDataCollector

        public boolean removeDataCollector​(java.lang.String name)
        Description copied from interface: StatisticsData
        Removes a registered Data-Collector, defined by name.
        Specified by:
        removeDataCollector in interface StatisticsData
        Parameters:
        name - String The name, defining the collector to be removed.
        Returns:
        boolean Indicating if Data-Collector has been removed sucessfull.
      • containsDataCollector

        public boolean containsDataCollector​(java.lang.String name)
        Description copied from interface: StatisticsData
        Find out, whether the Data-Collector identified by name is registered.
        Specified by:
        containsDataCollector in interface StatisticsData
        Parameters:
        name - String The name identifying the Data-Collector.
        Returns:
        boolean Indicates if the Data-Collector with name is registered.
      • putData

        public boolean putData​(java.lang.String name,
                               long timestamp,
                               float value)
        Description copied from interface: StatisticsData
        Method for putting one collected dataset consisting of a timestamp and a value.
        Specified by:
        putData in interface StatisticsData
        Parameters:
        name - The name of the data that are collected.
        timestamp - The time when the value has been collected, as milliseconds passed since 01.01.1970.
        value - The value that has been collected at specified time.
      • printStats

        protected void printStats​(java.lang.String name)
      • balanceDataLevels

        public void balanceDataLevels​(java.lang.String name)
        Description copied from interface: StatisticsData
        Method checks, if ticks held in different levels still observe the defined borders. If one Level contains data that must not be held by this level, the data is transfered into the next level, or regarding third level, dumped. This method should be called when the data-collector returns a value that does not need to be stored, to make sure that even if there are no new ticks added to the map, the contained data does not antiquate.
        Specified by:
        balanceDataLevels in interface StatisticsData
        Parameters:
        name - The name of the Collector that should be balanced.
      • trimAndAggregate

        protected void trimAndAggregate​(java.util.NavigableMap<java.lang.Long,​java.lang.Float> fromMap,
                                        java.util.NavigableMap<java.lang.Long,​java.lang.Float> toMap,
                                        long now,
                                        long millisToKeep,
                                        int ticksToRemoveAtOnce)
      • getTimePeriodData

        public java.lang.Object[][] getTimePeriodData​(java.lang.String name,
                                                      long start,
                                                      long end,
                                                      long utcOffset)
        Description copied from interface: StatisticsData
        Get the data of a speciific period of time from start till end.
        Specified by:
        getTimePeriodData in interface StatisticsData
        Parameters:
        name - The name of the data you want to get.
        start - The start-timestamp for the data.
        end - The end-timestamp for the data.
        utcOffset - The difference between local client time and UTC-time (server time) in ms.
        Returns:
        Map, containing the data during the given time period.
      • getAllData

        public java.lang.Object[][] getAllData​(java.lang.String name,
                                               int maxTicks,
                                               long utcOffset)
        Description copied from interface: StatisticsData
        Get all available data of the Data-Collector defined by name.
        Specified by:
        getAllData in interface StatisticsData
        Parameters:
        name - String The name defining the Data-Collector you want to get the Data from.
        maxTicks - The maximum number of ticks that will be returned.
        utcOffset - The difference between local client time and UTC-time (server time) in ms.
        Returns:
        Map The Map containing all Key-Value pairs of the Data-Collector with name name.
      • getTickAsArray

        public java.lang.Object[][] getTickAsArray​(java.lang.String name,
                                                   long period,
                                                   int maxTicks,
                                                   long utcOffset)
        Description copied from interface: StatisticsData
        Get time-period of length period in ms from Collector name as Object Array.
        Specified by:
        getTickAsArray in interface StatisticsData
        Parameters:
        name - The name identifying the DataCollector, which data is returned.
        period - Defines how long into past the time period should reach from now.
        maxTicks - Specifies the maximum number of Ticks that should be returned.
        utcOffset - The difference between local client time and UTC-time (server time) in ms.
        Returns:
        The Object[][] containing the x- and y-value for drawing a diagram.
      • getCurrentSize

        public int getCurrentSize​(java.lang.String name)
        Description copied from interface: StatisticsData
        Get the current size of the data-collector called name.
        Specified by:
        getCurrentSize in interface StatisticsData
        Returns:
        The current size of the stored data for collector called name.
      • getLevelSizes

        public int[] getLevelSizes​(java.lang.String name)
        Returns the tick-amount in the different level-sizes as int-Array.
        Parameters:
        name - The name of the Collector, the level-sizes should be returned for.
        Returns:
        Array containing the amount of ticks stored in the different levels.
      • setSizeLvl1Ms

        public void setSizeLvl1Ms​(long ms)
        Setter for the time-period ticks are stored in level-1.
      • setSizeLvl2Ms

        public void setSizeLvl2Ms​(long ms)
        Setter for the time-period, ticks are stored in level-2.
      • setSizeLvl3Ms

        public void setSizeLvl3Ms​(long ms)
        Setter for the time-period, ticks are stored in level-3.
      • getCollectorValue

        public float getCollectorValue​(java.lang.String name,
                                       long timestamp)
        Description copied from interface: StatisticsData
        Get one value of the collector called name at the given timestamp.
        Specified by:
        getCollectorValue in interface StatisticsData
        Parameters:
        name - The name of the collector.
        timestamp - The timestamp you want to have the value of.
        Returns:
        The value of the collector at the given timestamp. -1 if no such collector or timestamp available.