Class DefaultStatisticsData
- java.lang.Object
-
- de.hybris.platform.servicelayer.stats.DefaultStatisticsData
-
- All Implemented Interfaces:
StatisticsData
public class DefaultStatisticsData extends java.lang.Object implements StatisticsData
Class stores data collected by Collectors in a map.
-
-
Constructor Summary
Constructors Constructor Description DefaultStatisticsData()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddDataCollector(java.lang.String name)Method adds a new collector with key name.voidbalanceDataLevels(java.lang.String name)Method checks, if ticks held in different levels still observe the defined borders.booleancontainsDataCollector(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.floatgetCollectorValue(java.lang.String name, long timestamp)Get one value of the collector called name at the given timestamp.intgetCurrentSize(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 voidprintStats(java.lang.String name)booleanputData(java.lang.String name, long timestamp, float value)Method for putting one collected dataset consisting of a timestamp and a value.booleanremoveDataCollector(java.lang.String name)Removes a registered Data-Collector, defined by name.voidsetSizeLvl1Ms(long ms)Setter for the time-period ticks are stored in level-1.voidsetSizeLvl2Ms(long ms)Setter for the time-period, ticks are stored in level-2.voidsetSizeLvl3Ms(long ms)Setter for the time-period, ticks are stored in level-3.protected voidtrimAndAggregate(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)
-
-
-
Method Detail
-
addDataCollector
public boolean addDataCollector(java.lang.String name)
Description copied from interface:StatisticsDataMethod adds a new collector with key name.- Specified by:
addDataCollectorin interfaceStatisticsData- 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:StatisticsDataRemoves a registered Data-Collector, defined by name.- Specified by:
removeDataCollectorin interfaceStatisticsData- 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:StatisticsDataFind out, whether the Data-Collector identified by name is registered.- Specified by:
containsDataCollectorin interfaceStatisticsData- 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:StatisticsDataMethod for putting one collected dataset consisting of a timestamp and a value.- Specified by:
putDatain interfaceStatisticsData- 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:StatisticsDataMethod 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:
balanceDataLevelsin interfaceStatisticsData- 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:StatisticsDataGet the data of a speciific period of time from start till end.- Specified by:
getTimePeriodDatain interfaceStatisticsData- 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:StatisticsDataGet all available data of the Data-Collector defined by name.- Specified by:
getAllDatain interfaceStatisticsData- 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:StatisticsDataGet time-period of length period in ms from Collector name as Object Array.- Specified by:
getTickAsArrayin interfaceStatisticsData- 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:StatisticsDataGet the current size of the data-collector called name.- Specified by:
getCurrentSizein interfaceStatisticsData- 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:StatisticsDataGet one value of the collector called name at the given timestamp.- Specified by:
getCollectorValuein interfaceStatisticsData- 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.
-
-