Class StatisticsAccumulator

java.lang.Object
com.sun.corba.se.spi.monitoring.StatisticsAccumulator

public class StatisticsAccumulator extends Object

Author:
Hemanth Puttaswamy

StatisticsAccumulator accumulates the samples provided by the user and computes the value of minimum, maximum, sum and sample square sum. When the StatisticMonitoredAttribute calls getValue(), it will compute all the statistics for the collected samples (Which are Minimum, Maximum, Average, StandardDeviation) and provides a nice printable record as a String. Users can easily extend this class and provide the implementation of toString() method to format the stats as desired. By default all the stats are printed in a single line.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
     
    protected double
     
    protected String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct the Statistics Accumulator by providing the unit as a String.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected double
    If users choose to custom format the stats.
    protected double
    We use a derived Standard Deviation formula to compute SD.
    Computes the Standard Statistic Results based on the samples collected so far and provides the complete value as a formatted String
    void
    sample(double value)
    User will use this method to just register a sample with the StatisticsAccumulator.
    Users can extend StatisticsAccumulator to provide the complete Stats in the format they prefer, if the default format doesn't suffice.
    void
    unitTestValidate(String expectedUnit, double expectedMin, double expectedMax, long expectedSampleCount, double expectedAverage, double expectedStandardDeviation)
    This is an internal API to test StatisticsAccumulator...

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • max

      protected double max
    • min

      protected double min
    • unit

      protected String unit
  • Constructor Details

    • StatisticsAccumulator

      public StatisticsAccumulator(String unit)

      Construct the Statistics Accumulator by providing the unit as a String. The examples of units are "Hours", "Minutes", "Seconds", "MilliSeconds", "Micro Seconds" etc.,

      Parameters:
      unit - a String representing the units for the samples collected

  • Method Details

    • sample

      public void sample(double value)

      User will use this method to just register a sample with the StatisticsAccumulator. This is the only method that User will use to expose the statistics, internally the StatisticMonitoredAttribute will collect the information when requested from the ASAdmin.

      Parameters:
      value - a double value to make it more precise

    • getValue

      public String getValue()
      Computes the Standard Statistic Results based on the samples collected so far and provides the complete value as a formatted String
    • toString

      public String toString()
      Users can extend StatisticsAccumulator to provide the complete Stats in the format they prefer, if the default format doesn't suffice.
      Overrides:
      toString in class Object
    • computeAverage

      protected double computeAverage()
      If users choose to custom format the stats.
    • computeStandardDeviation

      protected double computeStandardDeviation()
      We use a derived Standard Deviation formula to compute SD. This way there is no need to hold on to all the samples provided. The method is protected to let users extend and format the results.
    • unitTestValidate

      public void unitTestValidate(String expectedUnit, double expectedMin, double expectedMax, long expectedSampleCount, double expectedAverage, double expectedStandardDeviation)
      This is an internal API to test StatisticsAccumulator...