Peter Royal wrote: > > Same problem, where are classes about caching ? I want to display what > > is in the cache and the number of hit for each one. > > You want to be looking at the debug output from the CachingEventPipeline and > the CachingStreamPipeline. Unfortunately it does not keep statistics on the > cache hit rate, but if you look at the debug output you can see if it did > pick up on the cached content or not.
Here is a patch against cocoon_20_branch, I don't know if you can apply it on HEAD (I did not test). Please, do NOT include it into cocoon_20_branch CVS on apache.org, it's working, but eat huge quantity of memory, and displayed data are raw. This is not for final administrators yet. What is inside: - New iterator() function on StoreJanitor. - Function added in StatusGenerator to display data in each store. - Changes on status2html stylesheet to display thoses data. Request http://localhost:8080/cocoon/status to see the result. Using a vanilia cocoon_20_branch, you have 3 different MRUMemoryStore (they have a different hashCode), with about 440 objects in each. Except for 2 object, all keys are presents in each Store. I think there is something wrong here. Is it my code ? -- Sébastien Koechlin - IVision - [EMAIL PROTECTED]
diff -u -r -x CVS xml-cocoon2.orig/src/org/apache/cocoon/components/store/StoreJanitor.java xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitor.java --- xml-cocoon2.orig/src/org/apache/cocoon/components/store/StoreJanitor.java Thu Dec 6 12:32:45 2001 +++ xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitor.java Wed +Dec 5 18:40:12 2001 @@ -23,4 +23,7 @@ /** unregister method for the stores */ void unregister(Store store); + + /** get an iterator to list registered stores */ + java.util.Iterator iterator(); } diff -u -r -x CVS xml-cocoon2.orig/src/org/apache/cocoon/components/store/StoreJanitorImpl.java xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitorImpl.java --- xml-cocoon2.orig/src/org/apache/cocoon/components/store/StoreJanitorImpl.java Thu Dec 6 12:32:46 2001 +++ xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitorImpl.java Wed +Dec 5 18:55:31 2001 @@ -16,6 +16,7 @@ import org.apache.avalon.framework.thread.ThreadSafe; import java.util.ArrayList; +import java.util.Iterator; /** * This class is a implentation of a StoreJanitor. Store classes @@ -168,6 +169,22 @@ this.getLogger().debug("Unregister store instance"); this.getLogger().debug("Size of StoreJanitor now:" + this.getStoreList().size()); } + } + + /** + * This method return a java.util.Iterator of every registered stores + * + * <i>The iterators returned is fail-fast: if list is structurally + * modified at any time after the iterator is created, in any way, the + * iterator will throw a ConcurrentModificationException. Thus, in the + * face of concurrent modification, the iterator fails quickly and + * cleanly, rather than risking arbitrary, non-deterministic behavior at + * an undetermined time in the future.</i> + * + * @return a java.util.Iterator + */ + public Iterator iterator() { + return this.getStoreList().iterator(); } /** diff -u -r -x CVS xml-cocoon2.orig/src/org/apache/cocoon/generation/StatusGenerator.java xml-cocoon2/src/org/apache/cocoon/generation/StatusGenerator.java --- xml-cocoon2.orig/src/org/apache/cocoon/generation/StatusGenerator.java Thu Dec 6 12:32:46 2001 +++ xml-cocoon2/src/org/apache/cocoon/generation/StatusGenerator.java Thu Dec 6 +12:05:13 2001 @@ -8,6 +8,11 @@ package org.apache.cocoon.generation; import org.apache.avalon.excalibur.pool.Recyclable; +import org.apache.cocoon.components.store.StoreJanitor; +import org.apache.cocoon.components.store.Store; +import org.apache.avalon.framework.component.ComponentException; +import org.apache.avalon.framework.component.ComponentManager; +import org.apache.avalon.framework.component.Composable; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; @@ -20,6 +25,8 @@ import java.util.Date; import java.util.List; import java.util.StringTokenizer; +import java.util.Iterator; +import java.util.Enumeration; /** Generates an XML representation of the current status of Cocoon. * Potted DTD: @@ -51,6 +58,8 @@ */ public class StatusGenerator extends ComposerGenerator implements Recyclable { + private StoreJanitor storejanitor = null; + /** The XML namespace for the output document. */ protected static final String namespace = @@ -61,6 +70,21 @@ protected static final String xlinkNamespace = "http://www.w3.org/1999/xlink"; + /** + * Set the current <code>ComponentManager</code> instance used by this + * <code>Composable</code>. + * Need to get statistics about cache hits + */ + public void compose(ComponentManager manager) throws ComponentException { + super.compose(manager); + this.storejanitor = (StoreJanitor)manager.lookup(StoreJanitor.ROLE); + if( this.storejanitor == null ) { + getLogger().debug("StoreJanitor is null, sorry no statistics"); + } else { + getLogger().debug("Got reference to StoreJanitor"); + }; + } + /** Generate the status information in XML format. * @throws SAXException * when there is a problem creating the output SAX events. @@ -142,6 +166,7 @@ endGroup(ch); // END operating system + // BEGIN ClassPath String classpath = System.getProperty("java.class.path"); List paths = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer(classpath, System.getProperty("path.separator")); @@ -149,6 +174,38 @@ paths.add(tokenizer.nextToken()); } addMultilineValue(ch, "classpath", paths); + // END ClassPath + + // BEGIN Cache + startGroup(ch, "Store-Janitor"); + + // For each element in StoreJanitor + Iterator i = this.storejanitor.iterator(); + while( i.hasNext() ) { + Store store = (Store) i.next(); + // For each element in Store + Enumeration e = store.keys(); + List cachelist = new ArrayList(); + while( e.hasMoreElements() ) { + Object o = e.nextElement(); + cachelist.add( + o.toString() + "( hash: " + + o.hashCode() + " | class: " + + o.getClass().getName() + + " )" + ); + }; + + startGroup(ch, store.getClass().getName()+" ("+cachelist.size()+" +items / "+store.hashCode()+")" ); + if( cachelist.isEmpty() ) { + addValue(ch, "cached", "[empty]"); + } else { + addMultilineValue(ch, "cached", cachelist); + }; + endGroup(ch); + }; + endGroup(ch); + // END Cache // BEGIN OS info endGroup(ch); diff -u -r -x CVS xml-cocoon2.orig/webapp/stylesheets/system/status2html.xsl xml-cocoon2/webapp/stylesheets/system/status2html.xsl --- xml-cocoon2.orig/webapp/stylesheets/system/status2html.xsl Thu Dec 6 12:32:51 2001 +++ xml-cocoon2/webapp/stylesheets/system/status2html.xsl Thu Dec 6 11:15:53 +2001 @@ -71,21 +71,45 @@ </xsl:template> - <xsl:template match="status:value"> - <tr> - <td bgcolor="#0086b2" valign="top" align="left"> - <FONT face="arial,helvetica,sanserif" color="#ffffff"> - <xsl:value-of select="@status:name"/> - </FONT> - </td> - <td bgcolor="ffffff" width="100%"> - <FONT face="arial,helvetica,sanserif"> - <xsl:value-of select="." /> - </FONT> - </td> - </tr> + <xsl:template match="status:value[count(status:line) <= 1]"> + <tr> + <td bgcolor="#0086b2" valign="top" align="left"> + <font face="arial,helvetica,sanserif" color="#ffffff"> + <xsl:value-of select="@status:name"/> + </font> + </td> + <td bgcolor="ffffff" width="100%"> + <font face="arial,helvetica,sanserif"> + <xsl:value-of select="status:line" /> + </font> + </td> + </tr> + </xsl:template> - </xsl:template> + + <xsl:template match="status:value[count(status:line) > 1]"> + <tr> + <td bgcolor="#0086b2" valign="top" align="left"> + <font face="arial,helvetica,sanserif" color="#ffffff"> + <xsl:value-of select="@status:name"/> + </font> + </td> + <td bgcolor="ffffff" width="100%"> + <ul> + <xsl:apply-templates /> + </ul> + </td> + </tr> + </xsl:template> + + + <xsl:template match="status:line"> + <li> + <font face="arial,helvetica,sanserif"> + <xsl:value-of select="." /> + </font> + </li> + </xsl:template> <xsl:template match="status:value[../@status:name='memory' and ( @status:name='total' or @status:name='free')]">
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]