stephan 2003/03/20 07:04:16
Modified: src/blocks/profiler/java/org/apache/cocoon/components/profiler
ProfilerData.java ProfilerResult.java
ProfilingCachingProcessingPipeline.java
ProfilingNonCachingProcessingPipeline.java
ProfilingXMLPipe.java
src/blocks/profiler/java/org/apache/cocoon/generation
ProfilerGenerator.java
src/blocks/profiler/samples profile2html.xsl
profile2page.xsl
src/java/org/apache/cocoon/components/pipeline/impl
AbstractCachingProcessingPipeline.java
Log:
Allow to profile the setup methods of the pipeline components (with
interesting results).
Revision Changes Path
1.2 +51 -46
cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilerData.java
Index: ProfilerData.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilerData.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilerData.java 9 Mar 2003 00:05:52 -0000 1.1
+++ ProfilerData.java 20 Mar 2003 15:04:14 -0000 1.2
@@ -62,15 +62,16 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version CVS $Id$
*/
-public class ProfilerData
-{
+public class ProfilerData {
+
/**
* Entry, which stores the role and source of a component from a pipeline.
*/
- public class Entry
- {
+ public class Entry {
+
public String role;
public String source;
+ public long setup;
public long time;
public Object fragment;
@@ -89,19 +90,24 @@
// Measured total time
private long totaltime = 0;
+ /**
+ * Create a new profiler dataset.
+ */
public ProfilerData() {
entries = new ArrayList();
}
/**
* Add new component from the pipeling, which should be measured.
- *
+ *
* @param component Component of the pipeline.
* @param role Role of the component.
* @param source Source attribute of the component.
*/
public void addComponent(Object component, String role, String source) {
- entries.add(new Entry(role!=null?role:component.getClass().getName(),
source));
+ entries.add(new Entry((role!=null)
+ ? role
+ : component.getClass().getName(), source));
}
/**
@@ -150,22 +156,43 @@
}
/**
- * Set measured time of the i-th component of the pipeline.
+ * Set measured setup time of the i-th component of the pipeline.
+ *
+ * @param index Index of the component.
+ * @param time Measured setup time of the component.
+ */
+ public void setSetupTime(int index, long time) {
+ ((Entry) entries.get(index)).setup = time;
+ }
+
+ /**
+ * Get measured setup time of the i-th component of the pipeline.
*
* @param index Index of the component.
- * @param time Measured time of the component.
+ * @return Measured setup time of the component.
*/
- public void setTime(int index, long time) {
- ((Entry)entries.get(index)).time = time;
+ public long getSetupTime(int index) {
+ return ((Entry) entries.get(index)).setup;
}
/**
- * Get measured time of the i-th component of the pipeline.
+ * Set measured processing time of the i-th component of the pipeline.
*
- * @return Measured time of the component.
+ * @param index Index of the component.
+ * @param time Measured processing time of the component.
*/
- public long getTime(int index) {
- return ((Entry)entries.get(index)).time;
+ public void setProcessingTime(int index, long time) {
+ ((Entry) entries.get(index)).time = time;
+ }
+
+ /**
+ * Get measured processing time of the i-th component of the pipeline.
+ *
+ * @param index Index of the component.
+ * @return Measured processing time of the component.
+ */
+ public long getProcessingTime(int index) {
+ return ((Entry) entries.get(index)).time;
}
/**
@@ -174,9 +201,8 @@
* @param index Index of the component.
* @param fragment SAX fragment of the component.
*/
- public void setSAXFragment(int index, Object fragment)
- {
- ((Entry)entries.get(index)).fragment = fragment;
+ public void setSAXFragment(int index, Object fragment) {
+ ((Entry) entries.get(index)).fragment = fragment;
}
/**
@@ -185,19 +211,20 @@
* @return Array of all entries.
*/
public Entry[] getEntries() {
- return (Entry[])entries.toArray(new Entry[entries.size()]);
+ return (Entry[]) entries.toArray(new Entry[entries.size()]);
}
/**
* Generate a key for a given URI for this pipeline
- *
+ *
+ * @param uri URI
* @return Hash key.
*/
- public long getKey(String uri)
- {
+ public long getKey(String uri) {
StringBuffer key = new StringBuffer(uri);
- for(int i=0; i<entries.size(); i++){
- Entry entry = (Entry)entries.get(i);
+
+ for (int i = 0; i<entries.size(); i++) {
+ Entry entry = (Entry) entries.get(i);
key.append(':');
key.append(entry.role);
@@ -206,26 +233,4 @@
}
return HashUtil.hash(key);
}
-
-/*
- public void report(String uri)
- {
-
System.err.println("-------------------------------------------------------------------------------");
- System.err.println("PROFILER DATA FOR: " + uri);
-
- Entry[] entries = getEntries();
- for(int i=0; i<entries.length; i++){
- long time = entries[i].time;
- if(i < entries.length - 1)
- time -= entries[i+1].time;
- if(entries[i].role == null || entries[i].role.length() == 0)
- System.err.println("PROFILER DATA: " + time
- + "\tFOR " + entries[i].component);
- else
- System.err.println("PROFILER DATA: " + time
- + "\tFOR " + entries[i].role + "\t" + entries[i].source);
- }
- System.err.println("PROFILER DATA: " + entries[0].time + " TOTAL");
- }
-*/
}
1.2 +32 -30
cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilerResult.java
Index: ProfilerResult.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilerResult.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilerResult.java 9 Mar 2003 00:05:52 -0000 1.1
+++ ProfilerResult.java 20 Mar 2003 15:04:14 -0000 1.2
@@ -81,8 +81,11 @@
// Total times of each request
private long[] totalTime;
- // Times of each component of the latest n-requests
- private long[][] latestTimes;
+ // Setup times of each component of the latest n-requests
+ private long[][] latestSetupTimes;
+
+ // Processing times of each component of the latest n-requests
+ private long[][] latestProcessingTimes;
// SAX fragments of eac component of the latest n-requests
private Object[][] latestFragments;
@@ -90,7 +93,8 @@
public ProfilerResult(String uri, int latestResultsCount) {
this.uri = uri;
this.latestEnvironmentInfo = new
EnvironmentInfo[(latestResultsCount>0)?latestResultsCount:5];
- this.latestTimes = new long[(latestResultsCount>0)?latestResultsCount:5][];
+ this.latestSetupTimes = new
long[(latestResultsCount>0)?latestResultsCount:5][];
+ this.latestProcessingTimes = new
long[(latestResultsCount>0)?latestResultsCount:5][];
this.totalTime = new long[(latestResultsCount>0)?latestResultsCount:5];
this.latestFragments = new
Object[(latestResultsCount>0)?latestResultsCount:5][];
this.count = 0;
@@ -115,24 +119,31 @@
this.count = 0;
}
- if (latestTimes != null) {
+ if (latestProcessingTimes != null) {
// move the current data
- for (int i = latestTimes.length - 1; i > 0; i--) {
+ for (int i = latestProcessingTimes.length - 1; i > 0; i--) {
latestEnvironmentInfo[i] = latestEnvironmentInfo[i - 1];
totalTime[i] = totalTime[i - 1];
- latestTimes[i] = latestTimes[i - 1];
+ latestSetupTimes[i] = latestSetupTimes[i - 1];
+ latestProcessingTimes[i] = latestProcessingTimes[i - 1];
latestFragments[i] = latestFragments[i - 1];
}
latestEnvironmentInfo[0] = data.getEnvironmentInfo();
totalTime[0] = data.getTotalTime();
- latestTimes[0] = new long[entries.length];
+
+ latestSetupTimes[0] = new long[entries.length];
+ for(int i=0; i<entries.length; i++)
+ this.latestSetupTimes[0][i] = entries[i].setup;
+
+ latestProcessingTimes[0] = new long[entries.length];
for(int i=0; i<entries.length; i++)
- this.latestTimes[0][i] = entries[i].time;
+ this.latestProcessingTimes[0][i] = entries[i].time;
+
latestFragments[0] = new Object[entries.length];
for(int i=0; i<entries.length; i++)
latestFragments[0][i] = entries[i].fragment;
- if (count<latestTimes.length)
+ if (count<latestProcessingTimes.length)
count++;
}
}
@@ -181,32 +192,23 @@
}
/**
- * Times of each component of the latest n-requests
+ * Setup times of each component of the latest n-requests
*/
- public long[][] getLastTimes() {
- return latestTimes;
+ public long[][] getSetupTimes() {
+ return latestSetupTimes;
+ }
+
+ /**
+ * Processing times of each component of the latest n-requests
+ */
+ public long[][] getProcessingTimes() {
+ return latestProcessingTimes;
}
/**
* SAX fragment of each component of the latest n-requests
*/
- public Object[][] getLatestSAXFragments() {
+ public Object[][] getSAXFragments() {
return latestFragments;
}
-
-/* public void report()
- {
-
System.err.println("-------------------------------------------------------------------------------");
- System.err.println("PROFILER TOTALS FOR: " + uri);
-
- if(totalTime != null){
- long time = 0;
- for(int i=0; i<totalTime.length; i++){
- System.err.println("PROFILER TOTALS: " + totalTime[i] + "\tFOR " +
roles[i] + "\t" + sources[i]);
- time += totalTime[i];
- }
- System.err.println("PROFILER TOTALS: " + time + " TIMES");
- System.err.println("PROFILER TOTALS: " + count + " REQUESTS");
- }
- }*/
}
1.2 +135 -33
cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilingCachingProcessingPipeline.java
Index: ProfilingCachingProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilingCachingProcessingPipeline.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilingCachingProcessingPipeline.java 9 Mar 2003 00:05:52 -0000 1.1
+++ ProfilingCachingProcessingPipeline.java 20 Mar 2003 15:04:14 -0000 1.2
@@ -50,15 +50,22 @@
*/
package org.apache.cocoon.components.profiler;
+import java.io.IOException;
+import java.util.Iterator;
+
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.generation.Generator;
+import org.apache.cocoon.transformation.Transformer;
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.cocoon.xml.XMLProducer;
+import org.xml.sax.SAXException;
+
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
@@ -66,7 +73,7 @@
* @version CVS $Id$
*/
public class ProfilingCachingProcessingPipeline
- extends CachingProcessingPipeline {
+ extends CachingProcessingPipeline {
private Profiler profiler;
@@ -76,19 +83,20 @@
/**
* Composable
+ *
+ * @param manager
*/
- public void compose(ComponentManager manager)
- throws ComponentException {
+ public void compose(ComponentManager manager) throws ComponentException {
super.compose(manager);
- this.profiler = (Profiler)manager.lookup(Profiler.ROLE);
+ this.profiler = (Profiler) manager.lookup(Profiler.ROLE);
}
/**
* Disposable
*/
public void dispose() {
- if (this.profiler != null){
+ if (this.profiler!=null) {
this.manager.release(this.profiler);
this.profiler = null;
}
@@ -114,15 +122,18 @@
* @param source the source where to produce XML from, or <code>null</code> if
no
* source is given.
* @param param the parameters for the generator.
+ * @param hintParam
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void setGenerator (String role, String source, Parameters param,
Parameters hintParam)
- throws ProcessingException {
+ public void setGenerator(String role, String source, Parameters param,
+ Parameters hintParam)
+ throws ProcessingException {
super.setGenerator(role, source, param, hintParam);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
+ }
this.data.addComponent(super.generator, role, source);
}
@@ -136,81 +147,172 @@
* @param source the source used to setup the transformer (e.g. XSL file), or
* <code>null</code> if no source is given.
* @param param the parameters for the transfomer.
+ * @param hintParam
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void addTransformer (String role, String source, Parameters param,
Parameters hintParam)
- throws ProcessingException {
+ public void addTransformer(String role, String source, Parameters param,
+ Parameters hintParam)
+ throws ProcessingException {
super.addTransformer(role, source, param, hintParam);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
- this.data.addComponent(super.transformers.get(super.transformers.size()-1),
role, source);
+ }
+ this.data.addComponent(super.transformers.get(super.transformers.size()-
+ 1), role, source);
}
/**
* Set the serializer for this pipeline
- * @param mimeType Can be null
+ *
+ * @param role
+ * @param source
+ * @param param
+ * @param hintParam
+ * @param mimeType
*/
- public void setSerializer (String role, String source, Parameters param,
Parameters hintParam, String mimeType)
- throws ProcessingException {
+ public void setSerializer(String role, String source, Parameters param,
+ Parameters hintParam,
+ String mimeType) throws ProcessingException {
super.setSerializer(role, source, param, hintParam, mimeType);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
+ }
this.data.addComponent(super.serializer, role, source);
}
- /**
+ /**
* Set the reader for this pipeline
- * @param mimeType Can be null
- */
- public void setReader (String role, String source, Parameters param, String
mimeType)
- throws ProcessingException {
+ *
+ * @param role
+ * @param source
+ * @param param
+ * @param mimeType
+ */
+ public void setReader(String role, String source, Parameters param,
+ String mimeType) throws ProcessingException {
super.setReader(role, source, param, mimeType);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
+ }
this.data.addComponent(super.reader, role, source);
}
/**
+ * Setup pipeline components.
+ *
+ * @param environment
+ */
+ protected void setupPipeline(Environment environment)
+ throws ProcessingException {
+ try {
+
+ // setup the generator
+ long time = System.currentTimeMillis();
+
+ this.generator.setup(environment, environment.getObjectModel(),
+ generatorSource, generatorParam);
+ this.data.setSetupTime(0, System.currentTimeMillis()-time);
+
+ Iterator transformerItt = this.transformers.iterator();
+ Iterator transformerSourceItt = this.transformerSources.iterator();
+ Iterator transformerParamItt = this.transformerParams.iterator();
+
+ int index = 1;
+
+ while (transformerItt.hasNext()) {
+ Transformer trans = (Transformer) transformerItt.next();
+
+ time = System.currentTimeMillis();
+ trans.setup(environment, environment.getObjectModel(),
+ (String) transformerSourceItt.next(),
+ (Parameters) transformerParamItt.next());
+ this.data.setSetupTime(index++,
+ System.currentTimeMillis()-time);
+ }
+
+ String mimeType = this.serializer.getMimeType();
+
+ if (mimeType!=null) {
+ // we have a mimeType from the component itself
+ environment.setContentType(mimeType);
+ } else if (serializerMimeType!=null) {
+ // there was a mimeType specified in the sitemap pipeline
+ environment.setContentType(serializerMimeType);
+ } else if (this.sitemapSerializerMimeType!=null) {
+ // use the mimeType specified in the sitemap component declaration
+ environment.setContentType(this.sitemapSerializerMimeType);
+ } else {
+ // No mimeType available
+ String message = "Unable to determine MIME type for "+
+ environment.getURIPrefix()+"/"+
+ environment.getURI();
+
+ throw new ProcessingException(message);
+ }
+ } catch (SAXException e) {
+ throw new ProcessingException("Could not setup pipeline.", e);
+ } catch (IOException e) {
+ throw new ProcessingException("Could not setup pipeline.", e);
+ }
+
+ // generate the key to fill the cache
+ this.generateCachingKey(environment);
+
+ // test the cache for a valid response
+ if (this.toCacheKey!=null) {
+ this.validatePipeline(environment);
+ }
+
+ this.setupValidities();
+ }
+
+ /**
* Process the given <code>Environment</code>, producing the output.
+ *
+ * @param environment
+ *
+ * @return
*/
public boolean process(Environment environment)
- throws ProcessingException {
+ throws ProcessingException {
this.index = 0;
- if (this.data != null) {
-
+ if (this.data!=null) {
// Capture environment info
this.data.setEnvironmentInfo(new EnvironmentInfo(environment));
// Execute pipeline
long time = System.currentTimeMillis();
boolean result = super.process(environment);
- this.data.setTotalTime(System.currentTimeMillis() - time);
+
+ this.data.setTotalTime(System.currentTimeMillis()-time);
// Report
profiler.addResult(environment.getURI(), this.data);
return result;
} else {
-
getLogger().warn("Profiler Data havn't any components to measure");
- return super.process( environment );
+ return super.process(environment);
}
}
/**
* Connect the next component
+ *
+ * @param environment
+ * @param producer
+ * @param consumer
*/
- protected void connect(Environment environment,
- XMLProducer producer,
- XMLConsumer consumer)
- throws ProcessingException {
+ protected void connect(Environment environment, XMLProducer producer,
+ XMLConsumer consumer) throws ProcessingException {
ProfilingXMLPipe connector = new ProfilingXMLPipe();
+
connector.setup(this.index, this.data);
this.index++;
super.connect(environment, producer, connector);
1.2 +125 -34
cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilingNonCachingProcessingPipeline.java
Index: ProfilingNonCachingProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilingNonCachingProcessingPipeline.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilingNonCachingProcessingPipeline.java 9 Mar 2003 00:05:52 -0000
1.1
+++ ProfilingNonCachingProcessingPipeline.java 20 Mar 2003 15:04:14 -0000
1.2
@@ -50,6 +50,9 @@
*/
package org.apache.cocoon.components.profiler;
+import java.io.IOException;
+import java.util.Iterator;
+
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
@@ -57,9 +60,13 @@
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.generation.Generator;
+import org.apache.cocoon.transformation.Transformer;
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.cocoon.xml.XMLProducer;
+import org.xml.sax.SAXException;
+
/**
* Special version of the NonCachingProcessingPipeline that supports capturing
* the SAX-events that go through it and stores the result in the
@@ -71,8 +78,7 @@
* @version CVS $Id$
*/
public class ProfilingNonCachingProcessingPipeline
- extends NonCachingProcessingPipeline
- implements Disposable {
+ extends NonCachingProcessingPipeline implements Disposable {
private Profiler profiler;
@@ -82,19 +88,20 @@
/**
* Composable
+ *
+ * @param manager
*/
- public void compose(ComponentManager manager)
- throws ComponentException {
+ public void compose(ComponentManager manager) throws ComponentException {
super.compose(manager);
- this.profiler = (Profiler)manager.lookup(Profiler.ROLE);
+ this.profiler = (Profiler) manager.lookup(Profiler.ROLE);
}
/**
* Disposable
*/
public void dispose() {
- if (this.profiler != null){
+ if (this.profiler!=null) {
this.manager.release(this.profiler);
this.profiler = null;
}
@@ -119,18 +126,21 @@
* @param source the source where to produce XML from, or <code>null</code> if
no
* source is given.
* @param param the parameters for the generator.
+ * @param hintParam
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void setGenerator (String role, String source, Parameters param,
Parameters hintParam)
- throws ProcessingException {
+ public void setGenerator(String role, String source, Parameters param,
+ Parameters hintParam)
+ throws ProcessingException {
super.setGenerator(role, source, param, hintParam);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
+ }
this.data.addComponent(super.generator, role, source);
}
-
+
/**
* Add a transformer at the end of the pipeline.
* The transformer role is given : the actual <code>Transformer</code> is
fetched
@@ -141,81 +151,162 @@
* @param source the source used to setup the transformer (e.g. XSL file), or
* <code>null</code> if no source is given.
* @param param the parameters for the transfomer.
+ * @param hintParam
* @throws ProcessingException if the generator couldn't be obtained.
*/
- public void addTransformer (String role, String source, Parameters param,
Parameters hintParam)
- throws ProcessingException {
+ public void addTransformer(String role, String source, Parameters param,
+ Parameters hintParam)
+ throws ProcessingException {
super.addTransformer(role, source, param, hintParam);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
- this.data.addComponent(super.transformers.get(super.transformers.size()-1),
role, source);
+ }
+ this.data.addComponent(super.transformers.get(super.transformers.size()-
+ 1), role, source);
}
/**
* Set the serializer for this pipeline
- * @param mimeType Can be null
+ *
+ * @param role
+ * @param source
+ * @param param
+ * @param hintParam
+ * @param mimeType
*/
- public void setSerializer (String role, String source, Parameters param,
Parameters hintParam, String mimeType)
- throws ProcessingException {
+ public void setSerializer(String role, String source, Parameters param,
+ Parameters hintParam,
+ String mimeType) throws ProcessingException {
super.setSerializer(role, source, param, hintParam, mimeType);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
+ }
this.data.addComponent(super.serializer, role, source);
}
- /**
+ /**
* Set the reader for this pipeline
- * @param mimeType Can be null
+ *
+ * @param role
+ * @param source
+ * @param param
+ * @param mimeType
*/
- public void setReader (String role, String source, Parameters param, String
mimeType)
- throws ProcessingException {
+ public void setReader(String role, String source, Parameters param,
+ String mimeType) throws ProcessingException {
super.setReader(role, source, param, mimeType);
- if(this.data == null)
+ if (this.data==null) {
this.data = new ProfilerData();
+ }
this.data.addComponent(super.reader, role, source);
}
/**
+ * Setup pipeline components.
+ *
+ * @param environment
+ */
+ protected void setupPipeline(Environment environment)
+ throws ProcessingException {
+ try {
+
+ // setup the generator
+ long time = System.currentTimeMillis();
+
+ this.generator.setup(environment, environment.getObjectModel(),
+ generatorSource, generatorParam);
+ this.data.setSetupTime(0, System.currentTimeMillis()-time);
+
+ Iterator transformerItt = this.transformers.iterator();
+ Iterator transformerSourceItt = this.transformerSources.iterator();
+ Iterator transformerParamItt = this.transformerParams.iterator();
+
+ int index = 1;
+
+ while (transformerItt.hasNext()) {
+ Transformer trans = (Transformer) transformerItt.next();
+
+ time = System.currentTimeMillis();
+ trans.setup(environment, environment.getObjectModel(),
+ (String) transformerSourceItt.next(),
+ (Parameters) transformerParamItt.next());
+ this.data.setSetupTime(index++,
+ System.currentTimeMillis()-time);
+ }
+
+ String mimeType = this.serializer.getMimeType();
+
+ if (mimeType!=null) {
+ // we have a mimeType from the component itself
+ environment.setContentType(mimeType);
+ } else if (serializerMimeType!=null) {
+ // there was a mimeType specified in the sitemap pipeline
+ environment.setContentType(serializerMimeType);
+ } else if (this.sitemapSerializerMimeType!=null) {
+ // use the mimeType specified in the sitemap component declaration
+ environment.setContentType(this.sitemapSerializerMimeType);
+ } else {
+ // No mimeType available
+ String message = "Unable to determine MIME type for "+
+ environment.getURIPrefix()+"/"+
+ environment.getURI();
+
+ throw new ProcessingException(message);
+ }
+ } catch (SAXException e) {
+ throw new ProcessingException("Could not setup pipeline.", e);
+ } catch (IOException e) {
+ throw new ProcessingException("Could not setup pipeline.", e);
+ }
+ }
+
+ /**
* Process the given <code>Environment</code>, producing the output.
+ *
+ * @param environment
+ *
+ * @return
*/
public boolean process(Environment environment)
- throws ProcessingException {
+ throws ProcessingException {
this.index = 0;
- if (this.data != null) {
-
+ if (this.data!=null) {
// Capture environment info
this.data.setEnvironmentInfo(new EnvironmentInfo(environment));
// Execute pipeline
long time = System.currentTimeMillis();
boolean result = super.process(environment);
- this.data.setTotalTime(System.currentTimeMillis() - time);
+
+ this.data.setTotalTime(System.currentTimeMillis()-time);
// Report
profiler.addResult(environment.getURI(), this.data);
return result;
} else {
-
getLogger().warn("Profiler Data havn't any components to measure");
- return super.process( environment );
+ return super.process(environment);
}
}
/**
* Connect the next component
+ *
+ * @param environment
+ * @param producer
+ * @param consumer
*/
- protected void connect(Environment environment,
- XMLProducer producer,
- XMLConsumer consumer)
- throws ProcessingException {
+ protected void connect(Environment environment, XMLProducer producer,
+ XMLConsumer consumer) throws ProcessingException {
ProfilingXMLPipe connector = new ProfilingXMLPipe();
+
connector.setup(this.index, this.data);
this.index++;
super.connect(environment, producer, connector);
1.2 +3 -3
cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilingXMLPipe.java
Index: ProfilingXMLPipe.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/components/profiler/ProfilingXMLPipe.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilingXMLPipe.java 9 Mar 2003 00:05:52 -0000 1.1
+++ ProfilingXMLPipe.java 20 Mar 2003 15:04:14 -0000 1.2
@@ -122,7 +122,7 @@
this.serializer.endDocument();
if (this.index != -1)
- this.data.setTime(this.index, this.total);
+ this.data.setProcessingTime(this.index, this.total);
// push the content of the buffer through the next component
Object fragment = this.serializer.getSAXFragment();
@@ -137,7 +137,7 @@
this.total = System.currentTimeMillis() - this.time;
if ((this.index != -1) && (this.index==(this.data.getCount()-2)))
- this.data.setTime(this.index+1, this.total);
+ this.data.setProcessingTime(this.index+1, this.total);
}
public void setDocumentLocator(Locator locator) {
1.2 +233 -132
cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/generation/ProfilerGenerator.java
Index: ProfilerGenerator.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/profiler/java/org/apache/cocoon/generation/ProfilerGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProfilerGenerator.java 9 Mar 2003 00:05:52 -0000 1.1
+++ ProfilerGenerator.java 20 Mar 2003 15:04:16 -0000 1.2
@@ -86,68 +86,75 @@
/**
* The XML PROFILER_NS for the output document.
*/
- protected static final String PROFILER_NS =
"http://apache.org/cocoon/profiler/1.0";
+ private static final String PROFILER_NS =
"http://apache.org/cocoon/profiler/1.0";
- protected static final String PROFILERINFO_ELEMENT = "profilerinfo";
- protected static final String RESULTS_ELEMENT = "pipeline";
- protected static final String RESULT_ELEMENT = "result";
- protected static final String AVERAGERESULT_ELEMENT = "average";
- protected static final String ENVIROMENTINFO_ELEMENT = "environmentinfo";
- protected static final String REQUESTPARAMETERS_ELEMENT = "request-parameters";
- protected static final String REQUESTPARAMETER_ELEMENT = "parameter";
- protected static final String SESSIONATTRIBUTES_ELEMENT = "session-attributes";
- protected static final String SESSIONATTRIBUTE_ELEMENT = "attribute";
- protected static final String COMPONENT_ELEMENT = "component";
- protected static final String FRAGMENT_ELEMENT = "fragment";
-
+ private static final String PROFILERINFO_ELEMENT = "profilerinfo";
+ private static final String RESULTS_ELEMENT = "pipeline";
+ private static final String RESULT_ELEMENT = "result";
+ private static final String AVERAGERESULT_ELEMENT = "average";
+ private static final String ENVIROMENTINFO_ELEMENT = "environmentinfo";
+ private static final String REQUESTPARAMETERS_ELEMENT = "request-parameters";
+ private static final String REQUESTPARAMETER_ELEMENT = "parameter";
+ private static final String SESSIONATTRIBUTES_ELEMENT = "session-attributes";
+ private static final String SESSIONATTRIBUTE_ELEMENT = "attribute";
+ private static final String COMPONENT_ELEMENT = "component";
+ private static final String FRAGMENT_ELEMENT = "fragment";
private Profiler profiler;
// the key identifying the ProfilerResult
- protected Long key = null;
+ private Long key = null;
- // Index of the result of latest results
- protected int resultIndex = -1;
+ // Index of the result of latest results
+ private int resultIndex = -1;
// Index of the componen of the latest results
- protected int componentIndex = -1;
+ private int componentIndex = -1;
/**
* Composable
*/
- public void compose(ComponentManager manager)
- throws ComponentException {
+ public void compose(ComponentManager manager) throws ComponentException {
super.compose(manager);
- this.profiler = (Profiler)super.manager.lookup(Profiler.ROLE);
+ this.profiler = (Profiler) super.manager.lookup(Profiler.ROLE);
}
- public void setup(SourceResolver resolver, Map objectModel, String soure,
Parameters parameters)
- throws ProcessingException, SAXException, IOException {
+ /**
+ * Setup of the profiler generator.
+ */
+ public void setup(SourceResolver resolver, Map objectModel, String soure,
+ Parameters parameters)
+ throws ProcessingException, SAXException,
+ IOException {
super.setup(resolver, objectModel, source, parameters);
Request request = ObjectModelHelper.getRequest(objectModel);
- if (request.getParameter("key")!=null)
+ if (request.getParameter("key")!=null) {
this.key = new Long(Long.parseLong(request.getParameter("key")));
- else
+ } else {
this.key = null;
+ }
- if ((request.getParameter("result")!=null) && (this.key!=null))
+ if ((request.getParameter("result")!=null) && (this.key!=null)) {
this.resultIndex = Integer.parseInt(request.getParameter("result"));
- else
+ } else {
this.resultIndex = -1;
+ }
- if ((request.getParameter("component")!=null) && (this.resultIndex!=-1))
+ if ((request.getParameter("component")!=null) &&
+ (this.resultIndex!=-1)) {
this.componentIndex =
Integer.parseInt(request.getParameter("component"));
- else
+ } else {
this.componentIndex = -1;
+ }
}
/**
* Disposable
*/
public void dispose() {
- if (this.profiler != null){
+ if (this.profiler!=null) {
super.manager.release(this.profiler);
this.profiler = null;
}
@@ -172,216 +179,310 @@
this.contentHandler.endDocument();
}
- /** Generate the main status document. */
+ /**
+ * Generate the main status document.
+ */
private void generateProfilerInfo() throws SAXException {
// Root element.
- // The current date and time.
+ // The current date and processingTime.
String dateTime = DateFormat.getDateTimeInstance().format(new Date());
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute(PROFILER_NS, "date", "date", "CDATA", dateTime);
- this.contentHandler.startElement(PROFILER_NS, PROFILERINFO_ELEMENT,
PROFILERINFO_ELEMENT, atts);
+
+ atts.addAttribute("", "date", "date", "CDATA", dateTime);
+ this.contentHandler.startElement(PROFILER_NS, PROFILERINFO_ELEMENT,
+ PROFILERINFO_ELEMENT, atts);
Collection resultsKeys = profiler.getResultKeys();
- for(Iterator i = resultsKeys.iterator(); i.hasNext();) {
- Long key = (Long)i.next();
- if ((this.key==null) || (this.key.equals(key)))
+
+ for (Iterator i = resultsKeys.iterator(); i.hasNext(); ) {
+ Long key = (Long) i.next();
+
+ if ((this.key==null) || (this.key.equals(key))) {
generateResults(key, profiler.getResult(key));
+ }
}
// End root element.
- this.contentHandler.endElement(PROFILER_NS, PROFILERINFO_ELEMENT,
PROFILERINFO_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS, PROFILERINFO_ELEMENT,
+ PROFILERINFO_ELEMENT);
}
- private void generateResults(Long key, ProfilerResult result) throws
SAXException {
+ /**
+ *
+ *
+ * @param key
+ * @param result
+ */
+ private void generateResults(Long key,
+ ProfilerResult result) throws SAXException {
AttributesImpl atts = new AttributesImpl();
int count = result.getCount();
- String[] roles = result.getRoles(); // Roles of the components
- String[] sources = result.getSources(); // Source of the components
-
+ String[] roles = result.getRoles(); // Roles of the
components
+ String[] sources = result.getSources(); // Source of the
components
+
EnvironmentInfo[] environmentInfos = result.getLatestEnvironmentInfos();
- long[] totalTime = result.getTotalTime(); // Total time of the requests
- long[][] timeOfComponents = result.getLastTimes(); // Time of each component
- Object[][] fragments = result.getLatestSAXFragments(); // SAX Fragments of
each component
+ long[] totalTime = result.getTotalTime(); // Total time of
the requests
+ long[][] setupTimes = result.getSetupTimes(); // Setup time of
each component
+ long[][] processingTimes = result.getProcessingTimes(); // Processing time
of each component
+ Object[][] fragments = result.getSAXFragments(); // SAX Fragments of
each component
// Total time of all requests
- long totalTimeSum = 0;
- for(int i=0; i < count; i++)
+ long totalTimeSum = 0;
+
+ for (int i = 0; i<count; i++)
totalTimeSum += totalTime[i];
- atts.addAttribute(PROFILER_NS, "uri", "uri", "CDATA", result.getURI());
- atts.addAttribute(PROFILER_NS, "count", "count", "CDATA",
Integer.toString(result.getCount()));
- atts.addAttribute(PROFILER_NS, "time", "time", "CDATA",
Long.toString(totalTimeSum));
- atts.addAttribute(PROFILER_NS, "key", "key", "CDATA", key.toString());
- this.contentHandler.startElement(PROFILER_NS, RESULTS_ELEMENT,
RESULTS_ELEMENT, atts);
+ atts.addAttribute("", "uri", "uri", "CDATA", result.getURI());
+ atts.addAttribute("", "count", "count", "CDATA",
+ Integer.toString(result.getCount()));
+ atts.addAttribute("", "processingTime", "processingTime", "CDATA",
+ Long.toString(totalTimeSum));
+ atts.addAttribute("", "key", "key", "CDATA", key.toString());
+ this.contentHandler.startElement(PROFILER_NS, RESULTS_ELEMENT,
+ RESULTS_ELEMENT, atts);
atts.clear();
- // Generate average result
- if ((count > 0) && (this.resultIndex==-1)) {
- atts.addAttribute(PROFILER_NS, "time", "time", "CDATA",
Long.toString(totalTimeSum / count));
- this.contentHandler.startElement(PROFILER_NS, AVERAGERESULT_ELEMENT,
AVERAGERESULT_ELEMENT, atts);
+ // Generate average result
+ if ((count>0) && (this.resultIndex==-1)) {
+ atts.addAttribute("", "time", "time", "CDATA",
+ Long.toString(totalTimeSum/count));
+ this.contentHandler.startElement(PROFILER_NS,
+ AVERAGERESULT_ELEMENT,
+ AVERAGERESULT_ELEMENT, atts);
atts.clear();
// Total time of each component for all requests
- long[] totalTimeOfComponents = new long[roles.length];
-
- for(int i=0; i<roles.length; i++) {
+ long[] totalTimeOfComponents = new long[roles.length];
+
+ for (int i = 0; i<roles.length; i++) {
totalTimeOfComponents[i] = 0;
- for(int j=0; j<count; j++) {
- totalTimeOfComponents[i] += timeOfComponents[j][i];
+ for (int j = 0; j<count; j++) {
+ totalTimeOfComponents[i] += setupTimes[j][i]+
+ processingTimes[j][i];
}
}
- for(int i=0; i<roles.length; i++){
- atts.addAttribute(PROFILER_NS, "offset", "offset", "CDATA",
String.valueOf(i));
-
- if(roles[i] != null)
- atts.addAttribute(PROFILER_NS, "role", "role", "CDATA",
roles[i]);
+ for (int i = 0; i<roles.length; i++) {
+ atts.addAttribute("", "offset", "offset", "CDATA",
+ String.valueOf(i));
- if(sources[i] != null)
- atts.addAttribute(PROFILER_NS, "source", "source", "CDATA",
sources[i]);
+ if (roles[i]!=null) {
+ atts.addAttribute("", "role", "role", "CDATA", roles[i]);
+ }
- atts.addAttribute(PROFILER_NS, "time", "time", "CDATA",
- Long.toString(totalTimeOfComponents[i] / count));
+ if (sources[i]!=null) {
+ atts.addAttribute("", "source", "source", "CDATA",
+ sources[i]);
+ }
- this.contentHandler.startElement(PROFILER_NS, COMPONENT_ELEMENT,
COMPONENT_ELEMENT, atts);
+ atts.addAttribute("", "time", "time", "CDATA",
+ Long.toString(totalTimeOfComponents[i]/
+ count));
+
+ this.contentHandler.startElement(PROFILER_NS,
+ COMPONENT_ELEMENT,
+ COMPONENT_ELEMENT, atts);
atts.clear();
- this.contentHandler.endElement(PROFILER_NS, COMPONENT_ELEMENT,
COMPONENT_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS,
+ COMPONENT_ELEMENT,
+ COMPONENT_ELEMENT);
}
- this.contentHandler.endElement(PROFILER_NS, AVERAGERESULT_ELEMENT,
AVERAGERESULT_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS,
+ AVERAGERESULT_ELEMENT,
+ AVERAGERESULT_ELEMENT);
}
- for(int j=0; j<count; j++) {
- if ((this.resultIndex==-1) || (this.resultIndex==j))
- generateResult(j, roles, sources, environmentInfos[j],
- totalTime[j], timeOfComponents[j], fragments[j]);
+ for (int j = 0; j<count; j++) {
+ if ((this.resultIndex==-1) || (this.resultIndex==j)) {
+ generateResult(j, roles, sources, environmentInfos[j],
+ totalTime[j], setupTimes[j],
+ processingTimes[j], fragments[j]);
+ }
}
- this.contentHandler.endElement(PROFILER_NS, RESULTS_ELEMENT,
RESULTS_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS, RESULTS_ELEMENT,
+ RESULTS_ELEMENT);
}
- private void generateResult(int resultIndex, String[] roles, String[] sources,
+ private void generateResult(int resultIndex, String[] roles,
+ String[] sources,
EnvironmentInfo environmentInfo,
- long totaltime, long[] times, Object[] fragments)
throws SAXException {
-
+ long totalTime, long[] setupTimes,
+ long[] processingTimes,
+ Object[] fragments) throws SAXException {
+
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute(PROFILER_NS, "time", "time", "CDATA",
Long.toString(totaltime));
- atts.addAttribute(PROFILER_NS, "index", "index", "CDATA",
String.valueOf(resultIndex));
- this.contentHandler.startElement(PROFILER_NS, RESULT_ELEMENT,
RESULT_ELEMENT, atts);
+
+ atts.addAttribute("", "time", "time", "CDATA",
+ Long.toString(totalTime));
+ atts.addAttribute("", "index", "index", "CDATA",
+ String.valueOf(resultIndex));
+ this.contentHandler.startElement(PROFILER_NS, RESULT_ELEMENT,
+ RESULT_ELEMENT, atts);
atts.clear();
- if (this.resultIndex!=-1)
+ if (this.resultIndex!=-1) {
generateEnvironmentInfo(environmentInfo);
+ }
- for(int i=0; i<roles.length; i++) {
- generateComponent(i, roles[i], sources[i], times[i], fragments[i]);
+ for (int i = 0; i<roles.length; i++) {
+ generateComponent(i, roles[i], sources[i], setupTimes[i],
+ processingTimes[i], fragments[i]);
}
- this.contentHandler.endElement(PROFILER_NS, RESULT_ELEMENT, RESULT_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS, RESULT_ELEMENT,
+ RESULT_ELEMENT);
}
- private void generateComponent(int componentIndex, String role, String source,
long time, Object fragment)
- throws SAXException {
+ private void generateComponent(int componentIndex, String role,
+ String source, long setupTime,
+ long processingTime,
+ Object fragment) throws SAXException {
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute(PROFILER_NS, "index", "index", "CDATA",
String.valueOf(componentIndex));
+ atts.addAttribute("", "index", "index", "CDATA",
+ String.valueOf(componentIndex));
+
+ if (role!=null) {
+ atts.addAttribute("", "role", "role", "CDATA", role);
+ }
+
+ if (source!=null) {
+ atts.addAttribute("", "source", "source", "CDATA", source);
+ }
- if (role != null)
- atts.addAttribute(PROFILER_NS, "role", "role", "CDATA", role);
+ atts.addAttribute("", "setup", "setup", "CDATA",
+ Long.toString(setupTime));
- if (source != null)
- atts.addAttribute(PROFILER_NS, "source", "source", "CDATA", source);
+ atts.addAttribute("", "processing", "processing", "CDATA",
+ Long.toString(processingTime));
- atts.addAttribute(PROFILER_NS, "time", "time", "CDATA",
Long.toString(time));
+ atts.addAttribute("", "time", "time", "CDATA",
+ Long.toString(setupTime+processingTime));
- this.contentHandler.startElement(PROFILER_NS, COMPONENT_ELEMENT,
COMPONENT_ELEMENT, atts);
+ this.contentHandler.startElement(PROFILER_NS, COMPONENT_ELEMENT,
+ COMPONENT_ELEMENT, atts);
atts.clear();
- if (this.componentIndex==componentIndex)
+ if (this.componentIndex==componentIndex) {
generateSAXFragment(fragment);
+ }
- this.contentHandler.endElement(PROFILER_NS, COMPONENT_ELEMENT,
COMPONENT_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS, COMPONENT_ELEMENT,
+ COMPONENT_ELEMENT);
}
- private void generateEnvironmentInfo(EnvironmentInfo environmentInfo) throws
SAXException {
- this.contentHandler.startElement(PROFILER_NS, ENVIROMENTINFO_ELEMENT,
ENVIROMENTINFO_ELEMENT,
+ private void generateEnvironmentInfo(EnvironmentInfo environmentInfo)
+ throws SAXException {
+ this.contentHandler.startElement(PROFILER_NS, ENVIROMENTINFO_ELEMENT,
+ ENVIROMENTINFO_ELEMENT,
new AttributesImpl());
- if (environmentInfo != null) {
+ if (environmentInfo!=null) {
// Generate SAX events for the request parameters
- this.contentHandler.startElement(PROFILER_NS,
REQUESTPARAMETERS_ELEMENT, REQUESTPARAMETERS_ELEMENT,
- new AttributesImpl());
+ this.contentHandler.startElement(PROFILER_NS,
+ REQUESTPARAMETERS_ELEMENT,
+ REQUESTPARAMETERS_ELEMENT,
+ new AttributesImpl());
Map requestParameters = environmentInfo.getRequestParameters();
Set requestParamEntries = requestParameters.entrySet();
Iterator requestParamEntriesIt = requestParamEntries.iterator();
+
while (requestParamEntriesIt.hasNext()) {
AttributesImpl atts = new AttributesImpl();
- Map.Entry entry = (Map.Entry)requestParamEntriesIt.next();
- atts.addAttribute(PROFILER_NS, "name", "name", "CDATA",
(String)entry.getKey());
- atts.addAttribute(PROFILER_NS, "value", "value", "CDATA",
(String)entry.getValue());
- this.contentHandler.startElement(PROFILER_NS,
REQUESTPARAMETER_ELEMENT,
- REQUESTPARAMETER_ELEMENT, atts);
- this.contentHandler.endElement(PROFILER_NS,
REQUESTPARAMETER_ELEMENT,
+ Map.Entry entry = (Map.Entry) requestParamEntriesIt.next();
+
+ atts.addAttribute("", "name", "name", "CDATA",
+ (String) entry.getKey());
+ atts.addAttribute("", "value", "value", "CDATA",
+ (String) entry.getValue());
+ this.contentHandler.startElement(PROFILER_NS,
+ REQUESTPARAMETER_ELEMENT,
+ REQUESTPARAMETER_ELEMENT,
+ atts);
+ this.contentHandler.endElement(PROFILER_NS,
+ REQUESTPARAMETER_ELEMENT,
REQUESTPARAMETER_ELEMENT);
}
- this.contentHandler.endElement(PROFILER_NS, REQUESTPARAMETERS_ELEMENT,
REQUESTPARAMETERS_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS,
+ REQUESTPARAMETERS_ELEMENT,
+ REQUESTPARAMETERS_ELEMENT);
// Generate SAX events for the session attributes
- this.contentHandler.startElement(PROFILER_NS,
SESSIONATTRIBUTES_ELEMENT, SESSIONATTRIBUTES_ELEMENT,
- new AttributesImpl());
+ this.contentHandler.startElement(PROFILER_NS,
+ SESSIONATTRIBUTES_ELEMENT,
+ SESSIONATTRIBUTES_ELEMENT,
+ new AttributesImpl());
Map sessionAttributes = environmentInfo.getSessionAttributes();
Set sessionAttrEntries = sessionAttributes.entrySet();
Iterator sessionAttrEntriesIt = sessionAttrEntries.iterator();
+
while (sessionAttrEntriesIt.hasNext()) {
AttributesImpl atts = new AttributesImpl();
- Map.Entry entry = (Map.Entry)sessionAttrEntriesIt.next();
- atts.addAttribute(PROFILER_NS, "name", "name", "CDATA",
(String)entry.getKey());
- atts.addAttribute(PROFILER_NS, "value", "value", "CDATA",
(String)entry.getValue());
- this.contentHandler.startElement(PROFILER_NS,
SESSIONATTRIBUTE_ELEMENT,
- SESSIONATTRIBUTE_ELEMENT, atts);
- this.contentHandler.endElement(PROFILER_NS,
SESSIONATTRIBUTE_ELEMENT,
+ Map.Entry entry = (Map.Entry) sessionAttrEntriesIt.next();
+
+ atts.addAttribute("", "name", "name", "CDATA",
+ (String) entry.getKey());
+ atts.addAttribute("", "value", "value", "CDATA",
+ (String) entry.getValue());
+ this.contentHandler.startElement(PROFILER_NS,
+ SESSIONATTRIBUTE_ELEMENT,
+ SESSIONATTRIBUTE_ELEMENT,
+ atts);
+ this.contentHandler.endElement(PROFILER_NS,
+ SESSIONATTRIBUTE_ELEMENT,
SESSIONATTRIBUTE_ELEMENT);
}
- this.contentHandler.endElement(PROFILER_NS, SESSIONATTRIBUTES_ELEMENT,
SESSIONATTRIBUTES_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS,
+ SESSIONATTRIBUTES_ELEMENT,
+ SESSIONATTRIBUTES_ELEMENT);
// And the rest
- this.contentHandler.startElement(PROFILER_NS, "uri", "uri", new
AttributesImpl());
- this.contentHandler.characters(environmentInfo.getURI().toCharArray(),
0,
- environmentInfo.getURI().length());
+ this.contentHandler.startElement(PROFILER_NS, "uri", "uri",
+ new AttributesImpl());
+ this.contentHandler.characters(environmentInfo.getURI().toCharArray(),
+ 0, environmentInfo.getURI().length());
this.contentHandler.endElement(PROFILER_NS, "uri", "uri");
}
- this.contentHandler.endElement(PROFILER_NS, ENVIROMENTINFO_ELEMENT,
ENVIROMENTINFO_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS, ENVIROMENTINFO_ELEMENT,
+ ENVIROMENTINFO_ELEMENT);
}
public void generateSAXFragment(Object fragment) throws SAXException {
if (fragment!=null) {
-
- this.contentHandler.startElement(PROFILER_NS, FRAGMENT_ELEMENT,
FRAGMENT_ELEMENT,
+ this.contentHandler.startElement(PROFILER_NS, FRAGMENT_ELEMENT,
+ FRAGMENT_ELEMENT,
new AttributesImpl());
XMLDeserializer deserializer = null;
+
try {
- deserializer =
(XMLDeserializer)this.manager.lookup(XMLDeserializer.ROLE);
+ deserializer = (XMLDeserializer)
this.manager.lookup(XMLDeserializer.ROLE);
deserializer.setConsumer(new IncludeXMLConsumer(this.xmlConsumer));
deserializer.deserialize(fragment);
} catch (ComponentException ce) {
- getLogger().debug("Could not retrieve XMLDeserializer component",
ce);
- throw new SAXException("Could not retrieve XMLDeserializer
component", ce);
+ getLogger().debug("Could not retrieve XMLDeserializer component",
+ ce);
+ throw new SAXException("Could not retrieve XMLDeserializer
component",
+ ce);
} catch (Exception e) {
getLogger().debug("Could not serialize SAX fragment", e);
throw new SAXException("Could not serialize SAX fragment", e);
- } finally {
- if (deserializer!=null)
+ } finally {
+ if (deserializer!=null) {
this.manager.release(deserializer);
+ }
}
- this.contentHandler.endElement(PROFILER_NS, FRAGMENT_ELEMENT,
FRAGMENT_ELEMENT);
+ this.contentHandler.endElement(PROFILER_NS, FRAGMENT_ELEMENT,
+ FRAGMENT_ELEMENT);
}
}
}
1.2 +24 -24 cocoon-2.1/src/blocks/profiler/samples/profile2html.xsl
Index: profile2html.xsl
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/profiler/samples/profile2html.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- profile2html.xsl 9 Mar 2003 00:05:54 -0000 1.1
+++ profile2html.xsl 20 Mar 2003 15:04:16 -0000 1.2
@@ -9,7 +9,7 @@
<xsl:template match="profile:profilerinfo">
<html>
<head>
- <title>Cocoon2 profile information [<xsl:value-of
select="@profile:date"/>]</title>
+ <title>Cocoon2 profile information [<xsl:value-of select="@date"/>]</title>
</head>
<body>
Sort results by <a href="?sort=uri">uri</a>,
@@ -19,17 +19,17 @@
<xsl:choose>
<xsl:when test="$sort = 'uri'">
<xsl:apply-templates select="profile:pipeline">
- <xsl:sort select="@profile:uri"/>
+ <xsl:sort select="@uri"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$sort = 'time'">
<xsl:apply-templates select="profile:pipeline">
- <xsl:sort select="@profile:time" data-type="number"/>
+ <xsl:sort select="@time" data-type="number"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$sort = 'count'">
<xsl:apply-templates select="profile:pipeline">
- <xsl:sort select="@profile:count" data-type="number"/>
+ <xsl:sort select="@count" data-type="number"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
@@ -54,17 +54,17 @@
</xsl:if>
<tr bgcolor="#C0C0FF">
<td colspan="3">
- <a href="[EMAIL PROTECTED]:key}">
- <font face="verdana"><strong><xsl:value-of
select="@profile:uri"/></strong></font>
- (<xsl:value-of select="@profile:count"/> results,
- total time: <xsl:value-of select="@profile:time"/>,
- average time: <xsl:value-of select="@profile:time div @profile:count"/>)
+ <a href="[EMAIL PROTECTED]">
+ <font face="verdana"><strong><xsl:value-of select="@uri"/></strong></font>
+ (<xsl:value-of select="@count"/> results,
+ total time: <xsl:value-of select="@time"/>,
+ average time: <xsl:value-of select="@time div @count"/>)
</a>
</td>
<xsl:for-each select="profile:result">
<td>
- <a href="?key={../@profile:key}&[EMAIL PROTECTED]:index}">
- <xsl:value-of select="@profile:index"/>
+ <a href="?key={../@key}&[EMAIL PROTECTED]">
+ <xsl:value-of select="@index"/>
</a>
</td>
</xsl:for-each>
@@ -82,22 +82,22 @@
<xsl:value-of select="$pos"/>
</td>
<td width="10%">
- <xsl:value-of select="@profile:role"/>
- <xsl:if test="@profile:source">
- (<xsl:value-of select="@profile:source"/>)
+ <xsl:value-of select="@role"/>
+ <xsl:if test="@source">
+ (<xsl:value-of select="@source"/>)
</xsl:if>
</td>
<xsl:for-each
select="../../profile:average/profile:component[position()=$pos]">
<th>
- <xsl:value-of select="@profile:time"/>
+ <xsl:value-of select="@time"/>
</th>
</xsl:for-each>
<xsl:for-each
select="../../profile:result/profile:component[position()=$pos]">
<td>
- <a
href="?key={../../@profile:key}&index={../@profile:index}&[EMAIL
PROTECTED]:offset}">
- <xsl:value-of select="@profile:time"/>
+ <a href="?key={../../@key}&index={../@index}&[EMAIL PROTECTED]">
+ <xsl:value-of select="@time"/>
</a>
</td>
</xsl:for-each>
@@ -115,12 +115,12 @@
</td>
<th>
- <xsl:value-of select="profile:average/@profile:time"/>
+ <xsl:value-of select="profile:average/@time"/>
</th>
<xsl:for-each select="profile:result">
<td>
- <xsl:value-of select="@profile:time"/>
+ <xsl:value-of select="@time"/>
</td>
</xsl:for-each>
@@ -135,7 +135,7 @@
<table cellspacing="0" cellpadding="0">
<tr>
<td>
- <xsl:value-of select="@profile:role"/>
+ <xsl:value-of select="@role"/>
</td>
</tr>
</table>
@@ -164,8 +164,8 @@
</xsl:variable>
<tr bgcolor="{$bgcolor}">
- <td><xsl:value-of select="@profile:name"/></td>
- <td><xsl:value-of select="@profile:value"/></td>
+ <td><xsl:value-of select="@name"/></td>
+ <td><xsl:value-of select="@value"/></td>
</tr>
</xsl:for-each>
</table>
@@ -189,8 +189,8 @@
</xsl:variable>
<tr bgcolor="{$bgcolor}">
- <td><xsl:value-of select="@profile:name"/></td>
- <td><xsl:value-of select="@profile:value"/></td>
+ <td><xsl:value-of select="@name"/></td>
+ <td><xsl:value-of select="@value"/></td>
</tr>
</xsl:for-each>
</table>
1.2 +38 -30 cocoon-2.1/src/blocks/profiler/samples/profile2page.xsl
Index: profile2page.xsl
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/profiler/samples/profile2page.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- profile2page.xsl 9 Mar 2003 00:05:54 -0000 1.1
+++ profile2page.xsl 20 Mar 2003 15:04:16 -0000 1.2
@@ -21,7 +21,7 @@
<xsl:choose>
<xsl:when test="$component!=''">
<xsl:apply-templates
-
select="profile:profilerinfo/profile:pipeline/profile:result/profile:[EMAIL
PROTECTED]:index=$component]"
+
select="profile:profilerinfo/profile:pipeline/profile:result/profile:[EMAIL PROTECTED]"
mode="fragment"/>
</xsl:when>
<xsl:when test="$result!=''">
@@ -56,19 +56,19 @@
<tr bgcolor="#FFFFFF">
<td>
- <a href="[EMAIL PROTECTED]:key}">
- <font face="verdana"><strong><xsl:value-of
select="@profile:uri"/></strong></font>
+ <a href="[EMAIL PROTECTED]">
+ <font face="verdana"><strong><xsl:value-of select="@uri"/></strong></font>
</a>
</td>
<td>
- <a href="[EMAIL PROTECTED]:key}">
- <xsl:value-of select="profile:average/@profile:time"/> ms
+ <a href="[EMAIL PROTECTED]">
+ <xsl:value-of select="profile:average/@time"/> ms
</a>
</td>
<xsl:for-each select="profile:result">
<td>
- <a href="?key={../@profile:key}&[EMAIL PROTECTED]:index}">
- <xsl:value-of select="@profile:time"/> ms
+ <a href="?key={../@key}&[EMAIL PROTECTED]">
+ <xsl:value-of select="@time"/> ms
</a>
</td>
</xsl:for-each>
@@ -87,7 +87,7 @@
<xsl:template match="profile:pipeline" mode="results">
<row>
- <column title="[EMAIL PROTECTED]:uri}">
+ <column title="[EMAIL PROTECTED]">
<table width="100%" cellspacing="0" cellpadding="5" align="left">
<font size="+0" face="arial,helvetica,sanserif" color="#000000">
@@ -107,22 +107,22 @@
<xsl:value-of select="$pos"/>
</td>
<td width="10%">
- <xsl:value-of select="@profile:role"/>
- <xsl:if test="@profile:source">
- (<xsl:value-of select="@profile:source"/>)
+ <xsl:value-of select="@role"/>
+ <xsl:if test="@source">
+ (<xsl:value-of select="@source"/>)
</xsl:if>
</td>
<xsl:for-each
select="../../profile:average/profile:component[position()=$pos]">
<td>
- <xsl:value-of select="@profile:time"/> ms
+ <xsl:value-of select="@time"/> ms
</td>
</xsl:for-each>
<xsl:for-each
select="../../profile:result/profile:component[position()=$pos]">
<td>
- <a
href="?key={../../@profile:key}&result={../@profile:index}&[EMAIL
PROTECTED]:index}">
- <xsl:value-of select="@profile:time"/> ms
+ <a href="?key={../../@key}&result={../@index}&[EMAIL PROTECTED]">
+ <xsl:value-of select="@time"/> ms
</a>
</td>
</xsl:for-each>
@@ -133,11 +133,11 @@
<tr>
<td></td>
<td><b>Total time</b></td>
- <td><b><xsl:value-of select="profile:result/@profile:time"/> ms</b></td>
+ <td><b><xsl:value-of select="profile:result/@time"/> ms</b></td>
<xsl:for-each select="profile:result">
<td>
<b>
- <xsl:value-of select="@profile:time"/> ms
+ <xsl:value-of select="@time"/> ms
</b>
</td>
</xsl:for-each>
@@ -154,28 +154,36 @@
<xsl:template match="profile:result" mode="result">
<row>
- <column title="{../@profile:uri}">
+ <column title="{../@uri}">
<table bgcolor="#ffffff" border="0" cellspacing="0" cellpadding="2"
width="100%" align="center">
<tr>
<td align="left"><b>Components</b></td>
- <td align="left"><b>Time</b></td>
+ <td align="left"><b>Total time</b></td>
+ <td align="left"><b>Setup time</b></td>
+ <td align="left"><b>Processing time</b></td>
</tr>
<xsl:for-each select="profile:component">
<tr>
<td>
- <a
href="?key={../../@profile:key}&result={../@profile:index}&[EMAIL
PROTECTED]:index}">
- <xsl:value-of select="@profile:role"/>
- <xsl:if test="@profile:source">
- (<xsl:value-of select="@profile:source"/>)
+ <a href="?key={../../@key}&result={../@index}&[EMAIL PROTECTED]">
+ <xsl:value-of select="@role"/>
+ <xsl:if test="@source">
+ (<xsl:value-of select="@source"/>)
</xsl:if>
</a>
</td>
<td>
- <xsl:value-of select="@profile:time"/> ms
+ <xsl:value-of select="@time"/> ms
+ </td>
+ <td>
+ <xsl:value-of select="@setup"/> ms
+ </td>
+ <td>
+ <xsl:value-of select="@processing"/> ms
</td>
</tr>
</xsl:for-each>
@@ -200,8 +208,8 @@
<xsl:for-each
select="profile:environmentinfo/profile:request-parameters/profile:parameter">
<tr>
- <td><xsl:value-of select="@profile:name"/></td>
- <td><xsl:value-of select="@profile:value"/></td>
+ <td><xsl:value-of select="@name"/></td>
+ <td><xsl:value-of select="@value"/></td>
</tr>
</xsl:for-each>
@@ -231,8 +239,8 @@
<xsl:for-each
select="profile:environmentinfo/profile:session-attributes/profile:attribute">
<tr>
- <td><xsl:value-of select="@profile:name"/></td>
- <td><xsl:value-of select="@profile:value"/></td>
+ <td><xsl:value-of select="@name"/></td>
+ <td><xsl:value-of select="@value"/></td>
</tr>
</xsl:for-each>
@@ -254,9 +262,9 @@
<row>
<column>
<xsl:attribute name="title">
- <xsl:value-of select="@profile:role"/>
- <xsl:if test="@profile:source">
- (<xsl:value-of select="@profile:source"/>)
+ <xsl:value-of select="@role"/>
+ <xsl:if test="@source">
+ (<xsl:value-of select="@source"/>)
</xsl:if>
</xsl:attribute>
1.3 +57 -49
cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Index: AbstractCachingProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractCachingProcessingPipeline.java 19 Mar 2003 15:42:15 -0000 1.2
+++ AbstractCachingProcessingPipeline.java 20 Mar 2003 15:04:16 -0000 1.3
@@ -393,6 +393,61 @@
}
/**
+ * Generate validity objects for the new response
+ */
+ protected void setupValidities()
+ throws ProcessingException {
+
+ if (this.toCacheKey != null) {
+ // only update validity objects if we cannot use
+ // a cached response or when the cached response does
+ // cache less than now is cacheable
+ if (this.fromCacheKey == null
+ || this.fromCacheKey.size() < this.toCacheKey.size()) {
+
+ this.toCacheSourceValidities = new
SourceValidity[this.toCacheKey.size()];
+ int len = this.toCacheSourceValidities.length;
+ int i = 0;
+ while (i < len) {
+ final SourceValidity validity =
this.getValidityForInternalPipeline(i);
+
+ if (validity == null) {
+ if (i > 0
+ && (this.fromCacheKey == null || i >
this.fromCacheKey.size())) {
+ // shorten key
+ for(int m=i; m < this.toCacheSourceValidities.length;
m++) {
+ this.toCacheKey.removeLastKey();
+ if (!this.cacheCompleteResponse) {
+ this.firstNotCacheableTransformerIndex--;
+ }
+ this.cacheCompleteResponse = false;
+ }
+ SourceValidity[] copy = new SourceValidity[i];
+ System.arraycopy(this.toCacheSourceValidities, 0,
+ copy, 0, copy.length);
+ this.toCacheSourceValidities = copy;
+ len = this.toCacheSourceValidities.length;
+ } else {
+ // caching is not possible!
+ this.toCacheKey = null;
+ this.toCacheSourceValidities = null;
+ this.cacheCompleteResponse = false;
+ len = 0;
+ }
+ } else {
+ this.toCacheSourceValidities[i] = validity;
+ }
+ i++;
+ }
+ } else {
+ // we don't have to cache
+ this.toCacheKey = null;
+ this.cacheCompleteResponse = false;
+ }
+ }
+ }
+
+ /**
* Calculate the key that can be used to get something from the cache, and
* handle expires properly.
*
@@ -602,55 +657,8 @@
if (this.toCacheKey != null) {
this.validatePipeline(environment);
}
-
- // now generate validity objects for the new response
- if (this.toCacheKey != null) {
- // only update validity objects if we cannot use
- // a cached response or when the cached response does
- // cache less than now is cacheable
- if (this.fromCacheKey == null
- || this.fromCacheKey.size() < this.toCacheKey.size()) {
-
- this.toCacheSourceValidities = new
SourceValidity[this.toCacheKey.size()];
- int len = this.toCacheSourceValidities.length;
- int i = 0;
- while (i < len) {
- final SourceValidity validity =
this.getValidityForInternalPipeline(i);
- if (validity == null) {
- if (i > 0
- && (this.fromCacheKey == null || i >
this.fromCacheKey.size())) {
- // shorten key
- for(int m=i; m < this.toCacheSourceValidities.length;
m++) {
- this.toCacheKey.removeLastKey();
- if (!this.cacheCompleteResponse) {
- this.firstNotCacheableTransformerIndex--;
- }
- this.cacheCompleteResponse = false;
- }
- SourceValidity[] copy = new SourceValidity[i];
- System.arraycopy(this.toCacheSourceValidities, 0,
- copy, 0, copy.length);
- this.toCacheSourceValidities = copy;
- len = this.toCacheSourceValidities.length;
- } else {
- // caching is not possible!
- this.toCacheKey = null;
- this.toCacheSourceValidities = null;
- this.cacheCompleteResponse = false;
- len = 0;
- }
- } else {
- this.toCacheSourceValidities[i] = validity;
- }
- i++;
- }
- } else {
- // we don't have to cache
- this.toCacheKey = null;
- this.cacheCompleteResponse = false;
- }
- }
+ this.setupValidities();
}
/**