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/29 07:17:29 UTC
svn commit: rev 30901 - excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl
Author: leif
Date: Wed Jul 28 22:17:28 2004
New Revision: 30901
Removed:
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/XMLUtils.java
Modified:
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractInstrumentSample.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractValueInstrumentSample.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/DefaultInstrumentManagerImpl.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentProxy.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentSample.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentableProxy.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MaximumValueInstrumentSample.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MeanValueInstrumentSample.java
excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MinimumValueInstrumentSample.java
Log:
Back out the addition of the manual generation of XML for state saves because it turned out to be 2~3 times slower than building a DOM of Configuration objects. It was checked in so it would exist in case I ever decide to go back and have another look at it.
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractInstrumentSample.java Wed Jul 28 22:17:28 2004
@@ -575,88 +575,6 @@
return state;
}
-
- /**
- * Saves the state to a StringBuffer using manual generation of XML. This
- * is much more efficient than creating a Configuration object and then
- * generating the XML.
- *
- * @param indent Base indentation to use when generating the XML. Ignored
- * if packed is true.
- * @param packed Create packed XML without whitespace if true, or pretty
- * human readable XML if false.
- *
- * @return The state encoded as XML.
- */
- public final String saveStateToString( String indent, boolean packed )
- {
- // If this sample is not configured and its lease time is 0, then it
- // is an artifact of a previous state file, so it should not be saved.
- if( ( !isConfigured() ) && ( getLeaseExpirationTime() <= 0 ) )
- {
- return "";
- }
-
- boolean update;
- int value;
- long time;
-
- StringBuffer sb = new StringBuffer();
- String childIndent = indent + " ";
-
- synchronized( this )
- {
- // Always update the sample so its state will be correct when saved.
- long now = System.currentTimeMillis();
- update = update( now );
- value = getValueInner();
- time = m_time;
-
- StringBuffer attrsSb = new StringBuffer();
- attrsSb.append( "<sample" );
- attrsSb.append( " type=\"" );
- attrsSb.append( InstrumentSampleUtils.getInstrumentSampleTypeName( getType() ) );
- attrsSb.append( "\" interval=\"" );
- attrsSb.append( Long.toString( m_interval ) );
- attrsSb.append( "\" size=\"" );
- attrsSb.append( Integer.toString( m_size ) );
- attrsSb.append( "\" time=\"" );
- attrsSb.append( Long.toString( m_time ) );
- attrsSb.append( "\"" );
- if( getLeaseExpirationTime() > 0 )
- {
- attrsSb.append( " lease-expiration=\"" );
- attrsSb.append( Long.toString( getLeaseExpirationTime() ) );
- attrsSb.append( "\"" );
-
- // If the sample is permanent then its description will be set in the configuration
- // file and does not need to be saved here as well.
- attrsSb.append( " description=\"" );
- attrsSb.append( XMLUtil.makeSafeAttribute( m_description ) );
- attrsSb.append( "\"" );
- }
-
- // Let subclasses add additional attributes.
- saveStateAttributes( attrsSb );
-
- attrsSb.append( ">" );
-
- sb.append( XMLUtil.buildLine( indent, packed, attrsSb.toString() ) );
-
- // Save the history samples so that the newest is first.
- sb.append( XMLUtil.buildLine( childIndent, packed,
- "<history>" + getHistoryList() + "</history>" ) );
-
- sb.append( XMLUtil.buildLine( indent, packed, "</sample>" ) );
- }
-
- if ( update )
- {
- updateListeners( value, time );
- }
-
- return sb.toString();
- }
/**
* Loads the state into the InstrumentSample.
@@ -795,15 +713,6 @@
* @param state State configuration.
*/
protected void saveState( DefaultConfiguration state )
- {
- }
-
- /**
- * Allow subclasses to add information into the saves state.
- *
- * @param StringBuffer to which attributes should be appended.
- */
- protected void saveStateAttributes( StringBuffer attrsSb )
{
}
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractValueInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractValueInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/AbstractValueInstrumentSample.java Wed Jul 28 22:17:28 2004
@@ -113,20 +113,6 @@
state.setAttribute( "value-count", Integer.toString( m_valueCount ) );
}
-
- /**
- * Allow subclasses to add information into the saves state.
- *
- * @param StringBuffer to which attributes should be appended.
- */
- protected void saveStateAttributes( StringBuffer attrsSb )
- {
- super.saveStateAttributes( attrsSb );
-
- attrsSb.append( " value-count=\"" );
- attrsSb.append( Integer.toString( m_valueCount ) );
- attrsSb.append( "\"" );
- }
/**
* Used to load the state, called from AbstractInstrumentSample.loadState();
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/DefaultInstrumentManagerImpl.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/DefaultInstrumentManagerImpl.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/DefaultInstrumentManagerImpl.java Wed Jul 28 22:17:28 2004
@@ -23,8 +23,6 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -971,24 +969,14 @@
public void saveStateToStream( OutputStream os )
throws Exception
{
- /*
Configuration stateConfig = saveStateToConfiguration();
// Ride on top of the Configuration classes to save the state.
DefaultConfigurationSerializer serializer = new DefaultConfigurationSerializer();
serializer.setIndent( true );
serializer.serialize( os, stateConfig );
- */
-
- PrintWriter out = new PrintWriter( new OutputStreamWriter( os, "UTF-8" ) );
- out.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" );
-
- out.print( saveStateToString( "", false ) );
-
- // Don't close the PrintWriter because it would close the underlying OutputStream.
- out.flush();
}
-
+
/**
* Returns the Instrument Manager's state as a Configuration object.
*
@@ -1006,7 +994,7 @@
for( int i = 0; i < instrumentableProxies.length; i++ )
{
- Configuration childState = instrumentableProxies[i].saveState();
+ Configuration childState = instrumentableProxies[ i ].saveState();
if ( childState != null )
{
state.addChild( childState );
@@ -1014,41 +1002,6 @@
}
return state;
- }
-
- /**
- * Saves the state to a StringBuffer using manual generation of XML. This
- * is much more efficient than creating a Configuration object and then
- * generating the XML.
- *
- * @param indent Base indentation to use when generating the XML. Ignored
- * if packed is true.
- * @param packed Create packed XML without whitespace if true, or pretty
- * human readable XML if false.
- *
- * @return The state encoded as XML.
- */
- public String saveStateToString( String indent, boolean packed )
- {
- StringBuffer sb = new StringBuffer();
- String childIndent = indent + " ";
-
- sb.append( XMLUtil.buildLine( indent, packed, "<instrument-manager-state>" ) );
-
- InstrumentableProxy[] instrumentableProxies = m_instrumentableProxyArray;
- if( instrumentableProxies == null )
- {
- instrumentableProxies = updateInstrumentableProxyArray();
- }
-
- for( int i = 0; i < instrumentableProxies.length; i++ )
- {
- sb.append( instrumentableProxies[i].saveStateToString( childIndent, packed ) );
- }
-
- sb.append( XMLUtil.buildLine( indent, packed, "</instrument-manager-state>" ) );
-
- return sb.toString();
}
/*---------------------------------------------------------------
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentProxy.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentProxy.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentProxy.java Wed Jul 28 22:17:28 2004
@@ -999,50 +999,6 @@
}
/**
- * Saves the state to a StringBuffer using manual generation of XML. This
- * is much more efficient than creating a Configuration object and then
- * generating the XML.
- *
- * @param indent Base indentation to use when generating the XML. Ignored
- * if packed is true.
- * @param packed Create packed XML without whitespace if true, or pretty
- * human readable XML if false.
- *
- * @return The state encoded as XML.
- */
- public String saveStateToString( String indent, boolean packed )
- {
- StringBuffer sb = new StringBuffer();
- boolean empty = true;
- String childIndent = indent + " ";
-
- sb.append( XMLUtil.buildLine( indent, packed,
- "<instrument name=\"" + m_name + "\">" ) );
-
- InstrumentSample[] samples = getInstrumentSamples();
- for ( int i = 0; i < samples.length; i++ )
- {
- String childState = samples[i].saveStateToString( childIndent, packed );
- if ( !childState.equals( "" ) )
- {
- empty = false;
- sb.append( childState );
- }
- }
-
- sb.append( XMLUtil.buildLine( indent, packed, "</instrument>" ) );
-
- if ( empty )
- {
- return "";
- }
- else
- {
- return sb.toString();
- }
- }
-
- /**
* Loads the state into the Instrument.
*
* @param state Configuration object to load state from.
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentSample.java Wed Jul 28 22:17:28 2004
@@ -197,20 +197,6 @@
Configuration saveState();
/**
- * Saves the state to a StringBuffer using manual generation of XML. This
- * is much more efficient than creating a Configuration object and then
- * generating the XML.
- *
- * @param indent Base indentation to use when generating the XML. Ignored
- * if packed is true.
- * @param packed Create packed XML without whitespace if true, or pretty
- * human readable XML if false.
- *
- * @return The state encoded as XML.
- */
- String saveStateToString( String indent, boolean packed );
-
- /**
* Loads the state into the InstrumentSample.
*
* @param state Configuration object to load state from.
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentableProxy.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentableProxy.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/InstrumentableProxy.java Wed Jul 28 22:17:28 2004
@@ -656,7 +656,7 @@
InstrumentableProxy[] childProxies = getChildInstrumentableProxies();
for( int i = 0; i < childProxies.length; i++ )
{
- Configuration childState = childProxies[i].saveState();
+ Configuration childState = childProxies[ i ].saveState();
if ( childState != null )
{
empty = false;
@@ -668,7 +668,7 @@
InstrumentProxy[] proxies = getInstrumentProxies();
for( int i = 0; i < proxies.length; i++ )
{
- Configuration childState = proxies[i].saveState();
+ Configuration childState = proxies[ i ].saveState();
if ( childState != null )
{
empty = false;
@@ -682,63 +682,6 @@
state = null;
}
return state;
- }
-
- /**
- * Saves the state to a StringBuffer using manual generation of XML. This
- * is much more efficient than creating a Configuration object and then
- * generating the XML.
- *
- * @param indent Base indentation to use when generating the XML. Ignored
- * if packed is true.
- * @param packed Create packed XML without whitespace if true, or pretty
- * human readable XML if false.
- *
- * @return The state encoded as XML.
- */
- public String saveStateToString( String indent, boolean packed )
- {
- StringBuffer sb = new StringBuffer();
- boolean empty = true;
- String childIndent = indent + " ";
-
- sb.append( XMLUtil.buildLine( indent, packed,
- "<instrumentable name=\"" + m_name + "\">" ) );
-
- // Save the child Instrumentables
- InstrumentableProxy[] childProxies = getChildInstrumentableProxies();
- for( int i = 0; i < childProxies.length; i++ )
- {
- String childState = childProxies[i].saveStateToString( childIndent, packed );
- if ( !childState.equals( "" ) )
- {
- empty = false;
- sb.append( childState );
- }
- }
-
- // Save the direct Instruments
- InstrumentProxy[] proxies = getInstrumentProxies();
- for( int i = 0; i < proxies.length; i++ )
- {
- String childState = proxies[i].saveStateToString( childIndent, packed );
- if ( !childState.equals( "" ) )
- {
- empty = false;
- sb.append( childState );
- }
- }
-
- sb.append( XMLUtil.buildLine( indent, packed, "</instrumentable>" ) );
-
- if ( empty )
- {
- return "";
- }
- else
- {
- return sb.toString();
- }
}
/**
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MaximumValueInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MaximumValueInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MaximumValueInstrumentSample.java Wed Jul 28 22:17:28 2004
@@ -109,20 +109,6 @@
state.setAttribute( "last-value", Integer.toString( m_lastValue ) );
}
-
- /**
- * Allow subclasses to add information into the saves state.
- *
- * @param StringBuffer to which attributes should be appended.
- */
- protected void saveStateAttributes( StringBuffer attrsSb )
- {
- super.saveStateAttributes( attrsSb );
-
- attrsSb.append( " last-value=\"" );
- attrsSb.append( Integer.toString( m_lastValue ) );
- attrsSb.append( "\"" );
- }
/**
* Used to load the state, called from AbstractInstrumentSample.loadState();
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MeanValueInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MeanValueInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MeanValueInstrumentSample.java Wed Jul 28 22:17:28 2004
@@ -110,20 +110,6 @@
state.setAttribute( "value-total", Long.toString( m_valueTotal ) );
}
-
- /**
- * Allow subclasses to add information into the saves state.
- *
- * @param StringBuffer to which attributes should be appended.
- */
- protected void saveStateAttributes( StringBuffer attrsSb )
- {
- super.saveStateAttributes( attrsSb );
-
- attrsSb.append( " value-total=\"" );
- attrsSb.append( Long.toString( m_valueTotal ) );
- attrsSb.append( "\"" );
- }
/**
* Used to load the state, called from AbstractInstrumentSample.loadState();
Modified: excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MinimumValueInstrumentSample.java
==============================================================================
--- excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MinimumValueInstrumentSample.java (original)
+++ excalibur/trunk/containerkit/instrument/mgr-impl/src/java/org/apache/excalibur/instrument/manager/impl/MinimumValueInstrumentSample.java Wed Jul 28 22:17:28 2004
@@ -109,20 +109,6 @@
state.setAttribute( "last-value", Integer.toString( m_lastValue ) );
}
-
- /**
- * Allow subclasses to add information into the saves state.
- *
- * @param StringBuffer to which attributes should be appended.
- */
- protected void saveStateAttributes( StringBuffer attrsSb )
- {
- super.saveStateAttributes( attrsSb );
-
- attrsSb.append( " last-value=\"" );
- attrsSb.append( Integer.toString( m_lastValue ) );
- attrsSb.append( "\"" );
- }
/**
* Used to load the state, called from AbstractInstrumentSample.loadState();
---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org