org.apache.excalibur.instrument.manager.impl
Class MeanValueInstrumentSample

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.excalibur.instrument.manager.impl.AbstractInstrumentSample
          extended by org.apache.excalibur.instrument.manager.impl.AbstractValueInstrumentSample
              extended by org.apache.excalibur.instrument.manager.impl.MeanValueInstrumentSample
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, InstrumentSample, org.apache.excalibur.instrument.manager.InstrumentListener, org.apache.excalibur.instrument.manager.ValueInstrumentListener

 class MeanValueInstrumentSample
extends AbstractValueInstrumentSample

A InstrumentSample which stores the mean value set during the sample period.

Author:
Avalon Development Team

Field Summary
private  long m_valueTotal
          Total of all values seen during the sample period.
 
Fields inherited from class org.apache.excalibur.instrument.manager.impl.AbstractValueInstrumentSample
m_lastValue, m_value, m_valueCount
 
Fields inherited from class org.apache.excalibur.instrument.manager.impl.AbstractInstrumentSample
m_time
 
Constructor Summary
MeanValueInstrumentSample(InstrumentProxy instrumentProxy, java.lang.String name, long interval, int size, java.lang.String description, long lease)
          Creates a new MeanValueInstrumentSample
 
Method Summary
protected  void advanceToNextSample(boolean reset)
          The current sample has already been stored.
 int getType()
          Returns the type of the Instrument Sample.
protected  void loadState(int value, org.apache.avalon.framework.configuration.Configuration state)
          Used to load the state, called from AbstractInstrumentSample.loadState();
protected  void setValueInner(int value, long time)
          Sets the current value of the sample.
protected  void writeStateAttributes(java.io.PrintWriter out)
          Allow subclasses to add information into the saved state.
 
Methods inherited from class org.apache.excalibur.instrument.manager.impl.AbstractValueInstrumentSample
getFillValue, getInstrumentType, getValueInner, setValue
 
Methods inherited from class org.apache.excalibur.instrument.manager.impl.AbstractInstrumentSample
addInstrumentSampleListener, expire, extendLease, getDescription, getDescriptor, getInstrumentProxy, getInterval, getLeaseExpirationTime, getName, getSize, getSnapshot, getStateVersion, getTime, getValue, isConfigured, loadState, makePermanent, removeInstrumentSampleListener, setConfigured, stateChanged, toString, update, updateListeners, writeState
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
 

Field Detail

m_valueTotal

private long m_valueTotal
Total of all values seen during the sample period.

Constructor Detail

MeanValueInstrumentSample

MeanValueInstrumentSample(InstrumentProxy instrumentProxy,
                          java.lang.String name,
                          long interval,
                          int size,
                          java.lang.String description,
                          long lease)
Creates a new MeanValueInstrumentSample

Parameters:
instrumentProxy - The InstrumentProxy which owns the InstrumentSample.
name - The name of the new InstrumentSample.
interval - The sample interval of the new InstrumentSample.
size - The number of samples to store as history. Assumes that size is at least 1.
description - The description of the new InstrumentSample.
lease - The length of the lease in milliseconds.
Method Detail

getType

public int getType()
Returns the type of the Instrument Sample.

Returns:
The type of the Instrument Sample.

advanceToNextSample

protected void advanceToNextSample(boolean reset)
The current sample has already been stored. Reset the current sample and move on to the next.

Should only be called when synchronized.

Overrides:
advanceToNextSample in class AbstractValueInstrumentSample
Parameters:
reset - True if the next sample should be reset.

writeStateAttributes

protected void writeStateAttributes(java.io.PrintWriter out)
Allow subclasses to add information into the saved state.

Overrides:
writeStateAttributes in class AbstractValueInstrumentSample
Parameters:
out - PrintWriter to write to.

loadState

protected void loadState(int value,
                         org.apache.avalon.framework.configuration.Configuration state)
                  throws org.apache.avalon.framework.configuration.ConfigurationException
Used to load the state, called from AbstractInstrumentSample.loadState();

Should only be called when synchronized.

Overrides:
loadState in class AbstractValueInstrumentSample
Parameters:
value - Current value loaded from the state.
state - Configuration object to load state from.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - If there were any problems loading the state.

setValueInner

protected void setValueInner(int value,
                             long time)
Sets the current value of the sample. The value will be set as the mean of the new value and other values seen during the sample period.

Specified by:
setValueInner in class AbstractValueInstrumentSample
Parameters:
value - New sample value.
time - Time that the new sample arrives.