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 ofMutableTimeStatistic
that eases the various statistical calculations.- Since:
- S1AS8.0
- Version:
- $Revision: 1.2 $
- Author:
- Kedar Mhaswade
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MutableTimeStatisticImpl(TimeStatistic initial)
Constructs an instance of this class from its immutable equivalent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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:- The maxTime, minTime and totTime of param must be same
- 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:- method count ++
- max time, min time and total time are accordingly adjusted
- Specified by:
incrementCount
in interfaceMutableTimeStatistic
- 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 interfaceMutableStatistic
-
unmodifiableView
public Statistic unmodifiableView()
This method is the essence of this class. Returns the unmodifiable view of this instance.- Specified by:
unmodifiableView
in interfaceMutableStatistic
- 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 interfaceMutableStatistic
- 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 interfaceTimeStatistic
-
getDescription
public String getDescription()
Description copied from interface:Statistic
A human-readable description of the Statistic.- Specified by:
getDescription
in interfaceStatistic
-
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 interfaceStatistic
-
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 interfaceTimeStatistic
-
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 interfaceTimeStatistic
-
getName
public String getName()
Description copied from interface:Statistic
The name of this 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 interfaceStatistic
-
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 interfaceTimeStatistic
-
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".
-
setDescription
public void setDescription(String s)
-
-