Class IntervalStatistic


  • public class IntervalStatistic
    extends java.lang.Object
    This class accumulate N last values for some statistic gathered during specified intervals. For instance, if there is some statistic, like count errors or number of bytes written to disk, instance of this class can be created to hold values for this statistic during the last 10 minutes, 1 hour, 1 day, 1 year and all times.
    Since:
    2018.1
    • Constructor Summary

      Constructors 
      Constructor Description
      IntervalStatistic​(TimeService timeService, java.lang.String periods)
      Create statistic
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(long amount)
      Adds specified amount to the statistic
      void add​(long time, long amount)
      Adds specified amount to the statistic
      java.util.List<IntervalStatistic.Metric> get()
      The statistics are recalculated
      void inc()
      increase statistics by one
      void inc​(long time)
      increase statistics by one
      • Methods inherited from class java.lang.Object

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

      • IntervalStatistic

        public IntervalStatistic​(@NotNull
                                 TimeService timeService,
                                 @Nullable
                                 java.lang.String periods)
        Create statistic
        Parameters:
        timeService - time service, it will be used to obtain current time; can`t be null
        periods - human readable configuration with ";" delimiter, like "10m; 1h; 1d; 30d; 1y"
    • Method Detail

      • add

        public void add​(long time,
                        long amount)
        Adds specified amount to the statistic
        Parameters:
        time - amount time
        amount - amount to add
      • add

        public void add​(long amount)
        Adds specified amount to the statistic
        Parameters:
        amount - amount to add
      • inc

        public void inc()
        increase statistics by one
      • inc

        public void inc​(long time)
        increase statistics by one
        Parameters:
        time - statistic time