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

java.lang.Object
  extended by com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl
All Implemented Interfaces:
MutableCountStatistic, MutableStatistic, Serializable, BoundaryStatistic, BoundedRangeStatistic, RangeStatistic, Statistic

public class MutableBoundedRangeStatisticImpl
extends Object
implements BoundedRangeStatistic, 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. By merely changing the count (which is a mandatory measurement), rest of the statistical information could be deduced.

Since:
S1AS8.0
Version:
1.0
Author:
Kedar Mhaswade
See Also:
for an immutable implementation, Serialized Form

Constructor Summary
MutableBoundedRangeStatisticImpl(BoundedRangeStatistic initial)
          Constructs an instance of MutableCountStatistic that encapsulates the given Statistic.
 
Method Summary
 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 getLowerBound()
          The lower limit of the value of this attribute.The upper limit of the value of this attribute.
 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.
 long getUpperBound()
          The upper limit of the value of this attribute.
 Statistic modifiableView()
          Returns an instance of Statistic whose state can be changed by the caller.
 void reset()
          Resets to the initial state.
 void setCount(long current)
          Changes the current value of the encapsulated BoundedRangeStatistic to the given value.
 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

MutableBoundedRangeStatisticImpl

public MutableBoundedRangeStatisticImpl(BoundedRangeStatistic 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 BoundedRangeStatistic 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 remaining meta data in the encapsulated statistic is unchanged. The upper and lower bounds are untouched.

Specified by:
reset in interface MutableStatistic

setCount

public void setCount(long current)
Changes the current value of the encapsulated BoundedRangeStatistic to the given value. Since this is the only mutator exposed here, here are the other side effects of calling this method: In a real-time system with actual probes for measurement, the lastSampleTime could be different from the instant when this method is called, but that is deemed insignificant.

Specified by:
setCount in interface MutableCountStatistic
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 BoundedRangeStatistic when its current value is queried/measured.

Specified by:
unmodifiableView in interface MutableStatistic
Returns:
instance of BoundedRangeStatistic
See Also:
reset(), setCount(long)

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

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

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

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.

getCurrent

public long getCurrent()
Description copied from interface: RangeStatistic
The current value of this attribute.

Specified by:
getCurrent in interface RangeStatistic

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 interface RangeStatistic

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 interface RangeStatistic

getLowerBound

public long getLowerBound()
Description copied from interface: BoundaryStatistic
The lower limit of the value of this attribute.The upper limit of the value of this attribute.

Specified by:
getLowerBound in interface BoundaryStatistic

getUpperBound

public long getUpperBound()
Description copied from interface: BoundaryStatistic
The upper limit of the value of this attribute.

Specified by:
getUpperBound in interface BoundaryStatistic

setDescription

public void setDescription(String s)


Copyright © 2012. All Rights Reserved.