Class MutableCountStatisticImpl
- java.lang.Object
-
- com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl
-
- All Implemented Interfaces:
MutableCountStatistic,MutableStatistic,Serializable,CountStatistic,Statistic
public class MutableCountStatisticImpl extends Object implements CountStatistic, MutableCountStatistic
An implementation of MutableCountStatistic that provides ways to change the state externally through mutators. Convenience class that is useful for components that gather the statistical data.- Since:
- S1AS8.0
- Version:
- 1.0
- Author:
- Kedar Mhaswade
- See Also:
for an immutable implementation, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MutableCountStatisticImpl(CountStatistic initial)Constructs an instance of MutableCountStatistic that encapsulates the given Statistic.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()The count since the last reset.StringgetDescription()A human-readable description of the Statistic.longgetLastSampleTime()The time of the last measurement represented as a long, whose value is the number of milliseconds since January 1, 1970, 00:00:00.StringgetName()The name of this Statistic.longgetStartTime()The time of the first measurement represented as a long, whose value is the number of milliseconds since January 1, 1970, 00:00:00.StringgetUnit()The unit of measurement for this Statistic.StatisticmodifiableView()Returns an instance of Statistic whose state can be changed by the caller.voidreset()Resets to the initial state.voidsetCount(long count)Changes the value of the encapsulated CountStatistic to the given value.voidsetDescription(String s)StatisticunmodifiableView()This method is the essence of this class.
-
-
-
Constructor Detail
-
MutableCountStatisticImpl
public MutableCountStatisticImpl(CountStatistic initial)
Constructs an instance of MutableCountStatistic 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 CountStatistic that represents initial state
-
-
Method Detail
-
reset
public void reset()
Resets to the initial state. It is guaranteed that following changes occur to the statistic if this method is called:- The current value is reset to its initial value.
- The lastSampleTime is reset to current time in milliseconds.
- The startTime is reset to lastSampleTime.
- Specified by:
resetin interfaceMutableStatistic
-
setCount
public void setCount(long count)
Changes the value of the encapsulated CountStatistic to the given value. Since this is the only mutator exposed here, here are the other side effects of calling this method:- lastSampleTime is set to current time in milliseconds.
- Specified by:
setCountin interfaceMutableCountStatistic- Parameters:
count- long that represents the current value of the Statistic.
-
unmodifiableView
public Statistic unmodifiableView()
This method is the essence of this class. It provides the read-only view of encapsulated Statistic. If the clients have to know the Statistic, this is what should be called by actual data collecting component to return the value to them. The principle advantage is from the data collecting component's standpoint, in that it does not have to create instances of CountStatistic when its current value is queried/measured.- Specified by:
unmodifiableViewin interfaceMutableStatistic- Returns:
- instance of CountStatistic
- See Also:
reset(),setCount(long)
-
getLastSampleTime
public long getLastSampleTime()
Description copied from interface:StatisticThe 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:
getLastSampleTimein interfaceStatistic
-
getStartTime
public long getStartTime()
Description copied from interface:StatisticThe 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:
getStartTimein interfaceStatistic
-
getName
public String getName()
Description copied from interface:StatisticThe name of this Statistic.
-
getDescription
public String getDescription()
Description copied from interface:StatisticA human-readable description of the Statistic.- Specified by:
getDescriptionin interfaceStatistic
-
getUnit
public String getUnit()
Description copied from interface:StatisticThe unit of measurement for this Statistic. Valid values for TimeStatistic measurements are "HOUR", "MINUTE", "SECOND", "MILLISECOND", "MICROSECOND" and "NANOSECOND".
-
modifiableView
public Statistic modifiableView()
Description copied from interface:MutableStatisticReturns 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:
modifiableViewin interfaceMutableStatistic- Returns:
- an instance of Statistic interface that should not be cached.
-
getCount
public long getCount()
Description copied from interface:CountStatisticThe count since the last reset.- Specified by:
getCountin interfaceCountStatistic
-
setDescription
public void setDescription(String s)
-
-