Class MutableTimeStatisticImpl

java.lang.Object
com.sun.enterprise.admin.monitor.stats.MutableTimeStatisticImpl
All Implemented Interfaces:
MutableStatistic, MutableTimeStatistic, Serializable, Statistic, TimeStatistic

public class MutableTimeStatisticImpl extends Object implements TimeStatistic, MutableTimeStatistic
An implementation of MutableTimeStatistic that eases the various statistical calculations.
Since:
S1AS8.0
Version:
$Revision: 1.2 $
Author:
Kedar Mhaswade
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an instance of this class from its immutable equivalent.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Number of times the operation was invoked since the beginning of this measurement.
    A human-readable description of the Statistic.
    long
    The time of the last measurement represented as a long, whose value is the number of milliseconds since January 1, 1970, 00:00:00.
    long
    The maximum amount of time taken to complete one invocation of this operation since the beginning of this measurement.
    long
    The minimum amount of time taken to complete one invocation of this operation since the beginning of this measurement.
    The name of this Statistic.
    long
    The time of the first measurement represented as a long, whose value is the number of milliseconds since January 1, 1970, 00:00:00.
    long
    This is the sum total of time taken to complete every invocation of this operation since the beginning of this measurement.
    The unit of measurement for this Statistic.
    void
    incrementCount(long current)
    Increments the count of operation execution by 1 and also increases the time consumed.
    Returns an instance of Statistic whose state can be changed by the caller.
    void
    Resets the Statistic.
    void
     
    This method is the essence of this class.

    Methods inherited from class java.lang.Object

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

    • MutableTimeStatisticImpl

      public MutableTimeStatisticImpl(TimeStatistic initial)
      Constructs an instance of this class from its immutable equivalent. Note that there are some constraints on the parameter passed:
      • The maxTime, minTime and totTime of param must be same
      Parameters:
      instance - of (immutable) TimeStatistic
  • Method Details

    • incrementCount

      public void incrementCount(long current)
      Increments the count of operation execution by 1 and also increases the time consumed. A successful execution of method will have all the data updated as:
      • method count ++
      • max time, min time and total time are accordingly adjusted
      Specified by:
      incrementCount in interface MutableTimeStatistic
      Parameters:
      current - long indicating time in whatever unit this statistic is calculated
    • reset

      public void reset()
      Resets the Statistic. Calling this method has following effect:
      • Initial state of this Statistic is restored as far as Count, Minimum/Maximum and Total time of execution is considered.
      Specified by:
      reset in interface MutableStatistic
    • unmodifiableView

      public Statistic unmodifiableView()
      This method is the essence of this class. Returns the unmodifiable view of this instance.
      Specified by:
      unmodifiableView in interface MutableStatistic
      Returns:
      an instance of TimeStatistic
    • modifiableView

      public Statistic modifiableView()
      Description copied from interface: MutableStatistic
      Returns an instance of Statistic whose state can be changed by the caller. It is important to know that caller should not cache the return value from this method. In general, there is a problem in this contract in that, a client would not know from a Stats.getCreateCount() method whether the return value is something that is being modified or is invariant. Hence the caller should not cache the returned value in a collection and then collectively process it. The main idea behind providing this method is to control the number of instances created (per Mahesh's Suggestion).
      Specified by:
      modifiableView in interface MutableStatistic
      Returns:
      an instance of Statistic interface that should not be cached.
    • getCount

      public long getCount()
      Description copied from interface: TimeStatistic
      Number of times the operation was invoked since the beginning of this measurement.
      Specified by:
      getCount in interface TimeStatistic
    • getDescription

      public String getDescription()
      Description copied from interface: Statistic
      A human-readable description of the Statistic.
      Specified by:
      getDescription in interface Statistic
    • getLastSampleTime

      public long getLastSampleTime()
      Description copied from interface: Statistic
      The time of the last measurement represented as a long, whose value is the number of milliseconds since January 1, 1970, 00:00:00.
      Specified by:
      getLastSampleTime in interface Statistic
    • getMaxTime

      public long getMaxTime()
      Description copied from interface: TimeStatistic
      The maximum amount of time taken to complete one invocation of this operation since the beginning of this measurement.
      Specified by:
      getMaxTime in interface TimeStatistic
    • getMinTime

      public long getMinTime()
      Description copied from interface: TimeStatistic
      The minimum amount of time taken to complete one invocation of this operation since the beginning of this measurement.
      Specified by:
      getMinTime in interface TimeStatistic
    • getName

      public String getName()
      Description copied from interface: Statistic
      The name of this Statistic.
      Specified by:
      getName in interface Statistic
    • getStartTime

      public long getStartTime()
      Description copied from interface: Statistic
      The time of the first measurement represented as a long, whose value is the number of milliseconds since January 1, 1970, 00:00:00.
      Specified by:
      getStartTime in interface Statistic
    • getTotalTime

      public long getTotalTime()
      Description copied from interface: TimeStatistic
      This is the sum total of time taken to complete every invocation of this operation since the beginning of this measurement. Dividing totalTime by count will give you the average execution time for this operation.
      Specified by:
      getTotalTime in interface TimeStatistic
    • getUnit

      public String getUnit()
      Description copied from interface: Statistic
      The unit of measurement for this Statistic. Valid values for TimeStatistic measurements are "HOUR", "MINUTE", "SECOND", "MILLISECOND", "MICROSECOND" and "NANOSECOND".
      Specified by:
      getUnit in interface Statistic
    • setDescription

      public void setDescription(String s)