com.sun.enterprise.admin.monitor.stats
Class MutableTimeStatisticImpl

java.lang.Object
  extended by 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:
Serialized Form

Constructor Summary
MutableTimeStatisticImpl(TimeStatistic initial)
          Constructs an instance of this class from its immutable equivalent.
 
Method Summary
 long getCount()
          Number of times the operation was invoked since the beginning of this measurement.
 String getDescription()
          A human-readable description of the Statistic.
 long getLastSampleTime()
          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 getMaxTime()
          The maximum amount of time taken to complete one invocation of this operation since the beginning of this measurement.
 long getMinTime()
          The minimum amount of time taken to complete one invocation of this operation since the beginning of this measurement.
 String getName()
          The name of this Statistic.
 long getStartTime()
          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 getTotalTime()
          This is the sum total of time taken to complete every invocation of this operation since the beginning of this measurement.
 String getUnit()
          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.
 Statistic modifiableView()
          Returns an instance of Statistic whose state can be changed by the caller.
 void reset()
          Resets the Statistic.
 void setDescription(String s)
           
 Statistic unmodifiableView()
          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 Detail

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:

Parameters:
instance - of (immutable) TimeStatistic
Method Detail

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:

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:

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)


Copyright © 2012. All Rights Reserved.