Class IntervalStatistic


  • public class IntervalStatistic
    extends 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 Detail

      • IntervalStatistic

        public IntervalStatistic​(@NotNull
                                 TimeService timeService,
                                 @Nullable
                                 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