You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@excalibur.apache.org by le...@apache.org on 2004/07/22 07:44:45 UTC
svn commit: rev 23136 - excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager
Author: leif
Date: Wed Jul 21 22:44:44 2004
New Revision: 23136
Modified:
excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/AbstractInstrumentSample.java
excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/CounterInstrumentSample.java
excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MaximumValueInstrumentSample.java
excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MeanValueInstrumentSample.java
excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MinimumValueInstrumentSample.java
Log:
Fix a problem where value sample history would be incorrectly reset to 0 when the sample had not been viewed or received any new values for longer than the total sample period.
Modified: excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/AbstractInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/AbstractInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/AbstractInstrumentSample.java Wed Jul 21 22:44:44 2004
@@ -152,7 +152,7 @@
// Calculate the maxAge
m_maxAge = m_size * m_interval;
- init();
+ init( 0 );
// Create the descriptor
m_descriptor = new InstrumentSampleDescriptorLocalImpl( this );
@@ -670,9 +670,11 @@
}
/**
- * Initializes the sample
+ * Initializes the sample.
+ *
+ * @param fillValue The value to fill the buffer with.
*/
- private void init()
+ private void init( int fillValue )
{
// Calculate an interval time based on the current time by removing the modulous
// value of the current time. This will allign the intervals to the start of computer
@@ -683,10 +685,17 @@
// History is build with m_value holding the current value and all previous values
// spanning accross 2 arrays that switch places as time progresses. This completely
// removes the need to manage large lists or do array copies.
- // All history values are 0 initially.
m_historyIndex = 0;
- m_historyOld = new int[ m_size - 1 ];
- m_historyNew = new int[ m_size - 1 ];
+ if ( m_historyOld == null )
+ {
+ m_historyOld = new int[ m_size - 1 ];
+ m_historyNew = new int[ m_size - 1 ];
+ }
+ for ( int i = 0; i < m_historyOld.length; i++ )
+ {
+ m_historyOld[i] = fillValue;
+ m_historyNew[i] = fillValue;
+ }
}
/**
@@ -751,6 +760,13 @@
protected abstract void advanceToNextSample();
/**
+ * Returns the value to use for filling in the buffer when time is skipped.
+ * <p>
+ * Should only be called when synchronized.
+ */
+ protected abstract int getFillValue();
+
+ /**
* Brings the InstrumentSample's time up to date so that a new value can be added.
* <p>
* Should only be called when synchronized.
@@ -776,7 +792,7 @@
{
// The history is too old, reset the sample.
advanceToNextSample();
- init();
+ init( getFillValue() );
}
else
{
Modified: excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/CounterInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/CounterInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/CounterInstrumentSample.java Wed Jul 21 22:44:44 2004
@@ -115,6 +115,16 @@
// Counts do not propagate, so always reset the count to 0.
m_count = 0;
}
+
+ /**
+ * Returns the value to use for filling in the buffer when time is skipped.
+ * <p>
+ * Should only be called when synchronized.
+ */
+ protected int getFillValue()
+ {
+ return 0;
+ }
/**
* Used to load the state, called from AbstractInstrumentSample.loadState();
Modified: excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MaximumValueInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MaximumValueInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MaximumValueInstrumentSample.java Wed Jul 21 22:44:44 2004
@@ -88,6 +88,16 @@
m_value = m_lastValue;
m_valueCount = 0;
}
+
+ /**
+ * Returns the value to use for filling in the buffer when time is skipped.
+ * <p>
+ * Should only be called when synchronized.
+ */
+ protected int getFillValue()
+ {
+ return m_lastValue;
+ }
/**
* Allow subclasses to add information into the saved state.
Modified: excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MeanValueInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MeanValueInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MeanValueInstrumentSample.java Wed Jul 21 22:44:44 2004
@@ -89,6 +89,16 @@
// be affected by the old.
m_valueCount = 0;
}
+
+ /**
+ * Returns the value to use for filling in the buffer when time is skipped.
+ * <p>
+ * Should only be called when synchronized.
+ */
+ protected int getFillValue()
+ {
+ return m_value;
+ }
/**
* Allow subclasses to add information into the saved state.
Modified: excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MinimumValueInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MinimumValueInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument-manager/impl/src/java/org/apache/excalibur/instrument/manager/MinimumValueInstrumentSample.java Wed Jul 21 22:44:44 2004
@@ -88,6 +88,16 @@
m_value = m_lastValue;
m_valueCount = 0;
}
+
+ /**
+ * Returns the value to use for filling in the buffer when time is skipped.
+ * <p>
+ * Should only be called when synchronized.
+ */
+ protected int getFillValue()
+ {
+ return m_lastValue;
+ }
/**
* Allow subclasses to add information into the saved state.
---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org