|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.excalibur.instrument.manager.impl.AbstractInstrumentSample
abstract class AbstractInstrumentSample
An AbstractInstrumentSample contains all of the functionality common to all InstrumentSamples.
Field Summary | |
---|---|
private boolean |
m_configured
Configured flag. |
private java.lang.String |
m_description
The description of the new InstrumentSample. |
private org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor |
m_descriptor
The Descriptor for the InstrumentSample. |
private boolean |
m_expired
True if the lease has expired. |
private int |
m_historyIndex
The Index into the history arrays. |
private int[] |
m_historyNew
The New half of the history array. |
private int[] |
m_historyOld
The Old half of the history array. |
private InstrumentProxy |
m_instrumentProxy
The InstrumentProxy which owns the InstrumentSample. |
private long |
m_interval
The sample interval of the new InstrumentSample. |
private long |
m_leaseExpirationTime
The time that the current lease expires. |
private org.apache.excalibur.instrument.manager.InstrumentSampleListener[] |
m_listeners
Array of registered InstrumentSampleListeners. |
private long |
m_maxAge
The maximum amount of time between updates before history will be wiped clean. |
private java.lang.String |
m_name
The name of the new InstrumentSample. |
private int |
m_size
The number of samples to store as history. |
private int |
m_stateVersion
State Version. |
protected long |
m_time
The UNIX time of the beginning of the sample. |
private static long |
m_zoneOffset
Stores the time-zone offset for this JVM. |
Constructor Summary | |
---|---|
protected |
AbstractInstrumentSample(InstrumentProxy instrumentProxy,
java.lang.String name,
long interval,
int size,
java.lang.String description,
long lease)
Creates a new AbstractInstrumentSample |
Method Summary | |
---|---|
void |
addInstrumentSampleListener(org.apache.excalibur.instrument.manager.InstrumentSampleListener listener)
Registers a InstrumentSampleListener with a InstrumentSample given a name. |
protected abstract void |
advanceToNextSample(boolean reset)
The current sample has already been stored. |
private long |
calculateSampleTime(long time)
Calculates the time of the sample which contains the specified time. |
void |
expire()
Tells the sample that its lease has expired. |
long |
extendLease(long lease)
Extends the lease to be lease milliseconds from the current time. |
java.lang.String |
getDescription()
Returns the description of the sample. |
org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor |
getDescriptor()
Returns a Descriptor for the InstrumentSample. |
protected abstract int |
getFillValue()
Returns the value to use for filling in the buffer when time is skipped. |
private java.lang.String |
getHistoryList()
Generates a comma separated list of history values. |
private int[] |
getHistorySnapshot()
Gets a snapshot of the samples. |
InstrumentProxy |
getInstrumentProxy()
Returns the InstrumentProxy which owns the InstrumentSample. |
long |
getInterval()
Returns the sample interval. |
long |
getLeaseExpirationTime()
Returns the time that the current lease expires. |
java.lang.String |
getName()
Returns the name of the sample. |
int |
getSize()
Returns the number of samples in the sample history. |
org.apache.excalibur.instrument.manager.InstrumentSampleSnapshot |
getSnapshot()
Obtains a static snapshot of the InstrumentSample. |
int |
getStateVersion()
Returns the stateVersion of the sample. |
long |
getTime()
Obtain the UNIX time of the beginning of the sample. |
int |
getValue()
Obtain the value of the sample. |
protected abstract int |
getValueInner()
Gets the current value. |
private void |
init(int fillValue)
Initializes the sample. |
boolean |
isConfigured()
Returns true if the Instrument was configured in the instrumentables section of the configuration. |
void |
loadState(org.apache.avalon.framework.configuration.Configuration state)
Loads the state into the InstrumentSample. |
protected abstract void |
loadState(int value,
org.apache.avalon.framework.configuration.Configuration state)
Used to load the state, called from AbstractInstrumentSample.loadState(); |
(package private) void |
makePermanent()
Called by the InstrumentProxy class during configuration to make the sample permanent. |
void |
removeInstrumentSampleListener(org.apache.excalibur.instrument.manager.InstrumentSampleListener listener)
Unregisters a InstrumentSampleListener from a InstrumentSample given a name. |
(package private) void |
setConfigured()
Sets the configured flag. |
protected void |
stateChanged()
Called whenever the state of the sample is changed. |
java.lang.String |
toString()
Returns a string representation of the sample. |
protected boolean |
update(long time,
boolean reset)
Brings the InstrumentSample's time up to date so that a new value can be added. |
protected void |
updateListeners(int value,
long time)
Notifies any listeners of a change. |
void |
writeState(java.io.PrintWriter out)
Writes the current state to a PrintWriter as XML. |
protected void |
writeStateAttributes(java.io.PrintWriter out)
Allow subclasses to add information into the saved state. |
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.excalibur.instrument.manager.impl.InstrumentSample |
---|
getInstrumentType, getType |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
---|
enableLogging |
Field Detail |
---|
private static long m_zoneOffset
private InstrumentProxy m_instrumentProxy
private boolean m_configured
private java.lang.String m_name
private long m_interval
private int m_size
private java.lang.String m_description
private org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor m_descriptor
private long m_maxAge
protected long m_time
private long m_leaseExpirationTime
private boolean m_expired
private int m_historyIndex
private int[] m_historyOld
private int[] m_historyNew
private org.apache.excalibur.instrument.manager.InstrumentSampleListener[] m_listeners
private int m_stateVersion
Constructor Detail |
---|
protected AbstractInstrumentSample(InstrumentProxy instrumentProxy, java.lang.String name, long interval, int size, java.lang.String description, long lease)
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 |
---|
public InstrumentProxy getInstrumentProxy()
getInstrumentProxy
in interface InstrumentSample
public boolean isConfigured()
isConfigured
in interface InstrumentSample
public final java.lang.String getName()
getName
in interface InstrumentSample
public final long getInterval()
getInterval
in interface InstrumentSample
public final int getSize()
getSize
in interface InstrumentSample
public final java.lang.String getDescription()
getDescription
in interface InstrumentSample
public org.apache.excalibur.instrument.manager.InstrumentSampleDescriptor getDescriptor()
getDescriptor
in interface InstrumentSample
public final int getValue()
getValue
in interface InstrumentSample
public final long getTime()
getTime
in interface InstrumentSample
public long getLeaseExpirationTime()
getLeaseExpirationTime
in interface InstrumentSample
public long extendLease(long lease)
extendLease
in interface InstrumentSample
lease
- The length of the lease in milliseconds.
public void expire()
expire
in interface InstrumentSample
public final org.apache.excalibur.instrument.manager.InstrumentSampleSnapshot getSnapshot()
getSnapshot
in interface InstrumentSample
public int getStateVersion()
getStateVersion
in interface InstrumentSample
public void addInstrumentSampleListener(org.apache.excalibur.instrument.manager.InstrumentSampleListener listener)
addInstrumentSampleListener
in interface InstrumentSample
listener
- The listener which should start receiving updates from the
InstrumentSample.public void removeInstrumentSampleListener(org.apache.excalibur.instrument.manager.InstrumentSampleListener listener)
removeInstrumentSampleListener
in interface InstrumentSample
listener
- The listener which should stop receiving updates from the
InstrumentSample.protected void updateListeners(int value, long time)
Make sure that this is called OUTSIDE of a synchrinization block.
value
- The new value.time
- The time that the new value was set.public void writeState(java.io.PrintWriter out)
writeState
in interface InstrumentSample
out
- The PrintWriter to which the state should be written.public final void loadState(org.apache.avalon.framework.configuration.Configuration state) throws org.apache.avalon.framework.configuration.ConfigurationException
loadState
in interface InstrumentSample
state
- Configuration object to load state from.
org.apache.avalon.framework.configuration.ConfigurationException
- If there were any problems loading the
state.void setConfigured()
private void init(int fillValue)
fillValue
- The value to fill the buffer with.protected void writeStateAttributes(java.io.PrintWriter out)
out
- PrintWriter to write to.protected abstract void loadState(int value, org.apache.avalon.framework.configuration.Configuration state) throws org.apache.avalon.framework.configuration.ConfigurationException
Should only be called when synchronized.
value
- Current value loaded from the state.state
- Configuration object to load state from.
org.apache.avalon.framework.configuration.ConfigurationException
- If there were any problems loading the
state.private long calculateSampleTime(long time)
time
- Time whose sample time is requested.protected abstract int getValueInner()
Should only be called when synchronized.
protected abstract void advanceToNextSample(boolean reset)
Should only be called when synchronized.
reset
- True if the next sample should be reset.protected abstract int getFillValue()
Should only be called when synchronized.
protected boolean update(long time, boolean reset)
Should only be called when synchronized.
time
- The time to which the InstrumentSample should be brought up to date.reset
- True if the next sample should be reset if an advance is necessary.
private int[] getHistorySnapshot()
Should only be called after an update when synchronized.
private java.lang.String getHistoryList()
Should only be called after an update when synchronized.
protected void stateChanged()
void makePermanent()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |