You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cr...@apache.org on 2002/09/16 16:05:49 UTC

cvs commit: xml-cocoon2/src/webapp/WEB-INF instrumentation.xconf web.xml

crafterm    2002/09/16 07:05:48

  Modified:    .        changes.xml
               lib      jars.xml
               src/java/org/apache/cocoon Cocoon.java
               src/java/org/apache/cocoon/servlet CocoonServlet.java
               src/webapp/WEB-INF web.xml
  Added:       lib/core excalibur-component-20020916.jar
                        excalibur-instrument-20020916.jar
                        excalibur-instrument-manager-20020916.jar
                        excalibur-instrument-manager-interfaces-20020916.jar
               lib/optional excalibur-altrmi-common-20020916.jar
                        excalibur-altrmi-server-impl-20020916.jar
                        excalibur-altrmi-server-interfaces-20020916.jar
               src/webapp/WEB-INF instrumentation.xconf
  Removed:     lib/core excalibur-component-20020820.jar
                        excalibur-instrument-20020820.jar
  Log:
  Added initial support for Avalon Excalibur instrumentation.
  
  Revision  Changes    Path
  1.248     +4 -1      xml-cocoon2/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/changes.xml,v
  retrieving revision 1.247
  retrieving revision 1.248
  diff -u -r1.247 -r1.248
  --- changes.xml	13 Sep 2002 07:30:50 -0000	1.247
  +++ changes.xml	16 Sep 2002 14:05:47 -0000	1.248
  @@ -40,6 +40,9 @@
    </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="MC" type="add">
  +   Added support for Avalon Excalibur instrumentation.
  +  </action>
     <action dev="CZ" type="add">
      Added CascadingIOException to wrap other exceptions when an IOException is thrown.
     </action>
  
  
  
  1.37      +42 -2     xml-cocoon2/lib/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/lib/jars.xml,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- jars.xml	9 Sep 2002 15:48:46 -0000	1.36
  +++ jars.xml	16 Sep 2002 14:05:47 -0000	1.37
  @@ -45,7 +45,7 @@
   	<description>Part of jakarta-avalon, it is a set of classes and patterns that
          support high level server development.</description>
   	<used-by>Cocoon</used-by>
  -	<lib>core/excalibur-component-20020820.jar</lib>
  +	<lib>core/excalibur-component-20020916.jar</lib>
   	<homepage>http://jakarta.apache.org/avalon/excalibur/</homepage>
    </file>
    <file>
  @@ -69,7 +69,23 @@
   	<description>Part of jakarta-avalon, it is a set of classes and patterns that
          support high level server development.</description>
   	<used-by>Cocoon</used-by>
  -	<lib>core/excalibur-instrument-20020820.jar</lib>
  +	<lib>core/excalibur-instrument-20020916.jar</lib>
  +	<homepage>http://jakarta.apache.org/avalon/excalibur/</homepage>
  + </file>
  + <file>
  +	<title>Avalon Excalibur Instrument Manager</title>
  +	<description>Part of jakarta-avalon, it is a set of classes and patterns that
  +       support high level server development.</description>
  +	<used-by>Cocoon</used-by>
  +	<lib>core/excalibur-instrument-manager-20020916.jar</lib>
  +	<homepage>http://jakarta.apache.org/avalon/excalibur/</homepage>
  + </file>
  + <file>
  +	<title>Avalon Excalibur Instrument Manager Interfaces</title>
  +	<description>Part of jakarta-avalon, it is a set of classes and patterns that
  +       support high level server development.</description>
  +	<used-by>Cocoon</used-by>
  +	<lib>core/excalibur-instrument-manager-interfaces-20020916.jar</lib>
   	<homepage>http://jakarta.apache.org/avalon/excalibur/</homepage>
    </file>
    <file>
  @@ -143,6 +159,30 @@
   	<used-by>Cocoon</used-by>
   	<lib>core/avalon-framework-20020627.jar</lib>
   	<homepage>http://jakarta.apache.org/avalon/framework/</homepage>
  + </file>
  + <file>
  +	<title>Avalon AltRMI Common</title>
  +	<description>Part of jakarta-avalon for communicating with a remote
  +       server.</description>
  +	<used-by>Cocoon</used-by>
  +	<lib>optional/excalibur-altrmi-common-20020916.jar</lib>
  +	<homepage>http://jakarta.apache.org/avalon/framework/</homepage>
  + </file>
  + <file>
  +	<title>Avalon AltRMI Server implementation</title>
  +	<description>Part of jakarta-avalon for communicating with a remote
  +       server.</description>
  +	<used-by>Cocoon</used-by>
  +	<lib>optional/excalibur-altrmi-server-impl-20020916.jar</lib>
  +	<homepage>http://jakarta.apache.org/avalon/framework/</homepage>
  + </file>
  + <file>
  +	<title>Avalon AltRMI Server interfaces</title>
  +	<description>Part of jakarta-avalon for communicating with a remote
  +       server.</description>
  +	<used-by>Cocoon</used-by>
  +	<lib>optional/excalibur-altrmi-server-interfaces-20020916.jar</lib>
  +	<homepage>http://jakarta.apache.org/avalon/excalibur/</homepage>
    </file>
    <file>
   	<title>Jakarta Commons Collections</title>
  
  
  
  1.1                  xml-cocoon2/lib/core/excalibur-component-20020916.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/core/excalibur-instrument-20020916.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/core/excalibur-instrument-manager-20020916.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/core/excalibur-instrument-manager-interfaces-20020916.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/optional/excalibur-altrmi-common-20020916.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/optional/excalibur-altrmi-server-impl-20020916.jar
  
  	<<Binary file>>
  
  
  1.1                  xml-cocoon2/lib/optional/excalibur-altrmi-server-interfaces-20020916.jar
  
  	<<Binary file>>
  
  
  1.38      +18 -2     xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java
  
  Index: Cocoon.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Cocoon.java	13 Sep 2002 06:46:29 -0000	1.37
  +++ Cocoon.java	16 Sep 2002 14:05:48 -0000	1.38
  @@ -79,6 +79,8 @@
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.environment.Session;
   import org.apache.cocoon.util.ClassUtils;
  +import org.apache.excalibur.instrument.InstrumentManageable;
  +import org.apache.excalibur.instrument.InstrumentManager;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.impl.URLSource;
   import org.xml.sax.InputSource;
  @@ -109,7 +111,8 @@
                      Processor,
                      Contextualizable,
                      Composable,
  -                   LogKitManageable {
  +                   LogKitManageable,
  +                   InstrumentManageable {
   
       /** The application context */
       private Context context;
  @@ -123,6 +126,9 @@
       /** The logkit manager */
       private LogKitManager logKitManager;
   
  +    /** The instrument manager */
  +    private InstrumentManager instrumentManager;
  +
       /** The classpath (null if not available) */
       private String classpath;
   
  @@ -209,6 +215,15 @@
       }
   
       /**
  +     * Set the <code>InstrumentManager</code> for this Cocoon instance.
  +     *
  +     * @param manager an <code>InstrumentManager</code> instance
  +     */
  +    public void setInstrumentManager(final InstrumentManager manager) {
  +        this.instrumentManager = manager;
  +    }
  +
  +    /**
        * The <code>initialize</code> method
        *
        * @exception Exception if an error occurs
  @@ -221,6 +236,7 @@
           }
           this.componentManager.enableLogging(getLogger().getChildLogger("manager"));
           this.componentManager.contextualize(this.context);
  +        this.componentManager.setInstrumentManager(this.instrumentManager);
   
           if (getLogger().isDebugEnabled()) {
               getLogger().debug("New Cocoon object.");
  
  
  
  1.35      +55 -2     xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- CocoonServlet.java	13 Aug 2002 17:46:46 -0000	1.34
  +++ CocoonServlet.java	16 Sep 2002 14:05:48 -0000	1.35
  @@ -77,6 +77,8 @@
   import org.apache.cocoon.util.IOUtils;
   import org.apache.cocoon.util.StringUtils;
   import org.apache.cocoon.util.log.CocoonLogFormatter;
  +import org.apache.excalibur.instrument.InstrumentManager;
  +import org.apache.excalibur.instrument.manager.DefaultInstrumentManager;
   import org.apache.log.ContextMap;
   import org.apache.log.Hierarchy;
   import org.apache.log.Logger;
  @@ -181,6 +183,11 @@
       private boolean manageExceptions;
   
       /**
  +     * Flag to enable avalon excalibur instrumentation of Cocoon.
  +     */
  +    private boolean enableInstrumentation;
  +
  +    /**
        * This is the path to the servlet context (or the result
        * of calling getRealPath('/') on the ServletContext.
        * Note, that this can be null.
  @@ -435,6 +442,15 @@
               }
           }
   
  +        value = conf.getInitParameter("enable-instrumentation");
  +        this.enableInstrumentation =
  +            "yes".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value);
  +        if (value == null) {
  +            if (log.isDebugEnabled()) {
  +                log.debug("enable-instrumentation was not set - defaulting to false.");
  +            }
  +        }
  +
           this.createCocoon();
       }
   
  @@ -1233,6 +1249,9 @@
               c.contextualize(this.appContext);
               c.compose(getParentComponentManager ());
               c.setLogKitManager(this.logKitManager);
  +            if (this.enableInstrumentation) {
  +                c.setInstrumentManager(getInstrumentManager());
  +            }
               c.initialize();
               this.creationTime = System.currentTimeMillis();
   
  @@ -1259,7 +1278,41 @@
       protected void updateEnvironment() throws ServletException {
           this.appContext.put(Constants.CONTEXT_CLASS_LOADER, classLoader);
           this.appContext.put(Constants.CONTEXT_CLASSPATH, getClassPath());
  -     }
  +    }
  +
  +    /**
  +     * Helper method to obtain an <code>InstrumentManager</code> instance
  +     *
  +     * @return an <code>InstrumentManager</code> instance
  +     */
  +    private InstrumentManager getInstrumentManager()
  +        throws Exception
  +    {
  +        String imConfig = getInitParameter("instrumentation-config");
  +        if (imConfig == null) {
  +            throw new ServletException("Please define the init-param 'instrumentation-config' in your web.xml");
  +        }
  +
  +        final InputStream is = this.servletContext.getResourceAsStream(imConfig);
  +        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        final Configuration conf = builder.build(is);
  +
  +        // Get the logger for the instrument manager
  +        Logger imLogger =
  +            this.logKitManager.getLogger(conf.getAttribute( "logger", "core.instrument" ));
  +
  +        // Set up the Instrument Manager
  +        DefaultInstrumentManager instrumentManager = new DefaultInstrumentManager();
  +        instrumentManager.enableLogging(new LogKitLogger(imLogger));
  +        instrumentManager.configure(conf);
  +        instrumentManager.initialize();
  +
  +        if (log.isDebugEnabled()) {
  +            log.debug("Instrument manager created " + instrumentManager);
  +        }
  +
  +        return instrumentManager;
  +    }
   
       private String processTime(long time) throws IOException {
   
  
  
  
  1.18      +20 -1     xml-cocoon2/src/webapp/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/webapp/WEB-INF/web.xml,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- web.xml	19 Aug 2002 12:36:56 -0000	1.17
  +++ web.xml	16 Sep 2002 14:05:48 -0000	1.18
  @@ -222,7 +222,26 @@
         <param-value>true</param-value>
       </init-param>
       
  -    
  +    <!--
  +       If true, Avalon Excalibur instrumentation will be enabled on all Instrumentable
  +       components with Cocoon and your Cocoon application.
  +
  +    <init-param>
  +      <param-name>enable-instrumentation</param-name>
  +      <param-value>true</param-value>
  +    </init-param>
  +    -->
  +
  +    <!--
  +       This defines the location of the instrument manager configuration, only used
  +       if the init-param enable-instrumentation is enabled.
  +
  +    <init-param>
  +      <param-name>instrumentation-config</param-name>
  +      <param-value>/WEB-INF/instrumentation.xconf</param-value>
  +    </init-param>    
  +    -->
  +
       <!--
         This parameter allows you to startup Cocoon2 immediately after startup
         of your servlet engine.
  
  
  
  1.1                  xml-cocoon2/src/webapp/WEB-INF/instrumentation.xconf
  
  Index: instrumentation.xconf
  ===================================================================
  <instrument logger="core.instrument">
      <name>Cocoon</name>
      <description>Cocoon Sample Application</description>
      
      <connectors>
          <connector class="altrmi" port="15555"/>
      </connectors>
      
      <state-file interval="60000" use-compact-samples="true">cocoon.sampledata</state-file>
      
      <instrumentables>
          <instrumentable name="instrument-manager" description="Instrument Manager">
              <instrument name="active-thread-count" description="Active Thread Count">
                  <sample type="max" interval="1000" size="600" description="Maximum each second."/>
              </instrument>
              
              <instrument name="total-memory" description="Total Memory">
                  <sample type="max" interval="1000" size="600" description="Maximum each second."/>
              </instrument>
              
              <instrument name="free-memory" description="Free Memory">
                  <sample type="min" interval="1000" size="600" description="Minimum each second."/>
              </instrument>
              
              <instrument name="memory" description="In-Use Memory">
                  <sample type="max" interval="1000" size="600" description="Maximum each second."/>
              </instrument>
          </instrumentable>
      </instrumentables>
  </instrument>
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org