Class MutableAverageRangeStatisticImpl
- java.lang.Object
-
- com.sun.enterprise.admin.monitor.stats.MutableAverageRangeStatisticImpl
-
- All Implemented Interfaces:
AverageRangeStatistic
,MutableCountStatistic
,MutableStatistic
,Serializable
,RangeStatistic
,Statistic
public class MutableAverageRangeStatisticImpl extends Object implements AverageRangeStatistic, MutableCountStatistic
An implementation of AverageRangeStatistic that provides ways to change the state externally through mutators. Convenience class that is useful for components that gather the statistical data. By merely changing the count (which is a mandatory measurement), rest of the statistical information could be deduced.- Since:
- S1AS8.1
- Version:
- 1.0
- Author:
- Larry White, Kedar Mhaswade
- See Also:
for an immutable implementation
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_MAX_BOUND
DEFAULT_UPPER_BOUND is maximum value Long can attain
-
Constructor Summary
Constructors Constructor Description MutableAverageRangeStatisticImpl(BoundedRangeStatistic initial)
Constructs an instance of MutableAverageRangeStatisticImpl that encapsulates the given Statistic.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getAverage()
long
getCurrent()
The current value of this attribute.String
getDescription()
A human-readable description of the Statistic.long
getHighWaterMark()
The highest value this attribute has held since the beginning of the measurement.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
getLowWaterMark()
The lowest value this attribute has held since the beginning of the 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.String
getUnit()
The unit of measurement for this Statistic.Statistic
modifiableView()
Returns an instance of Statistic whose state can be changed by the caller.void
reset()
Resets the encapsulated Statistic interface to its initial value.void
setCount(long current)
Provides the mutator to the only statistic in the implementing class that changes - Count.Statistic
unmodifiableView()
Returns a read-only view of this Statistic.
-
-
-
Field Detail
-
DEFAULT_MAX_BOUND
public static final long DEFAULT_MAX_BOUND
DEFAULT_UPPER_BOUND is maximum value Long can attain- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MutableAverageRangeStatisticImpl
public MutableAverageRangeStatisticImpl(BoundedRangeStatistic initial)
Constructs an instance of MutableAverageRangeStatisticImpl that encapsulates the given Statistic. The only parameter denotes the initial state of this statistic. It is guaranteed that the initial state is preserved internally, so that one can reset to the initial state.- Parameters:
initial
- an instance of BoundedRangeStatistic that represents initial state
-
-
Method Detail
-
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.
-
unmodifiableView
public Statistic unmodifiableView()
Description copied from interface:MutableStatistic
Returns a read-only view of this Statistic. An implementing class has to return the instances of Statistic interfaces defined injavax.management.j2ee.statistic
andcom.sun.enterprise.admin.monitor.stats
packages.- Specified by:
unmodifiableView
in interfaceMutableStatistic
- Returns:
- an instance of a specific Statistic interface
-
reset
public void reset()
Description copied from interface:MutableStatistic
Resets the encapsulated Statistic interface to its initial value. The idea being, if (after creation of the instance) the state changes, the initial state can be easily regained by calling this method. Note that the time of last sampling changes to the instant when this method is invoked.- Specified by:
reset
in interfaceMutableStatistic
-
setCount
public void setCount(long current)
Description copied from interface:MutableCountStatistic
Provides the mutator to the only statistic in the implementing class that changes - Count. It is expected that the count is monotonically increasing on a temporal scale.- Specified by:
setCount
in interfaceMutableCountStatistic
- Parameters:
current
- long that specifies the value when measured (sampled).
-
getAverage
public long getAverage()
- Specified by:
getAverage
in interfaceAverageRangeStatistic
-
getCurrent
public long getCurrent()
Description copied from interface:RangeStatistic
The current value of this attribute.- Specified by:
getCurrent
in interfaceRangeStatistic
-
getDescription
public String getDescription()
Description copied from interface:Statistic
A human-readable description of the Statistic.- Specified by:
getDescription
in interfaceStatistic
-
getHighWaterMark
public long getHighWaterMark()
Description copied from interface:RangeStatistic
The highest value this attribute has held since the beginning of the measurement.- Specified by:
getHighWaterMark
in interfaceRangeStatistic
-
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
-
getLowWaterMark
public long getLowWaterMark()
Description copied from interface:RangeStatistic
The lowest value this attribute has held since the beginning of the measurement.- Specified by:
getLowWaterMark
in interfaceRangeStatistic
-
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
-
-