You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2003/01/15 01:19:17 UTC

cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardWrapperValve.java

costin      2003/01/14 16:19:16

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardWrapperValve.java
  Log:
  Collect information about processing time, errors, requestCounts.
  
  Revision  Changes    Path
  1.8       +52 -5     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java
  
  Index: StandardWrapperValve.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StandardWrapperValve.java	25 Nov 2002 21:03:50 -0000	1.7
  +++ StandardWrapperValve.java	15 Jan 2003 00:19:16 -0000	1.8
  @@ -124,6 +124,14 @@
        */
       private FilterDef filterDef = null;
   
  +    // Some JMX statistics. This vavle is associated with a StandardWrapper.
  +    // We exponse the StandardWrapper as JMX ( j2eeType=Servlet ). The fields
  +    // are here for performance.
  +    private long processingTime;
  +    private long maxTime;
  +    private int requestCount;
  +    private int errorCount;
  +
   
       /**
        * The descriptive information related to this implementation.
  @@ -173,6 +181,9 @@
           // Initialize local variables we may need
           boolean unavailable = false;
           Throwable throwable = null;
  +        // This should be a Request attribute...
  +        long t1=System.currentTimeMillis();
  +        requestCount++;
           StandardWrapper wrapper = (StandardWrapper) getContainer();
           ServletRequest sreq = request.getRequest();
           ServletResponse sres = response.getResponse();
  @@ -354,6 +365,11 @@
                   exception(request, response, e);
               }
           }
  +        long t2=System.currentTimeMillis();
  +
  +        long time=t2-t1;
  +        processingTime += time;
  +        if( time > maxTime) maxTime=time;
   
       }
   
  @@ -373,7 +389,7 @@
        */
       private void exception(Request request, Response response,
                              Throwable exception) {
  -
  +        errorCount++;
           ServletRequest sreq = request.getRequest();
           sreq.setAttribute(Globals.EXCEPTION_ATTR, exception);
   
  @@ -435,5 +451,36 @@
   
       }
   
  +    public long getProcessingTime() {
  +        return processingTime;
  +    }
  +
  +    public void setProcessingTime(long processingTime) {
  +        this.processingTime = processingTime;
  +    }
  +
  +    public long getMaxTime() {
  +        return maxTime;
  +    }
  +
  +    public void setMaxTime(long maxTime) {
  +        this.maxTime = maxTime;
  +    }
  +
  +    public int getRequestCount() {
  +        return requestCount;
  +    }
  +
  +    public void setRequestCount(int requestCount) {
  +        this.requestCount = requestCount;
  +    }
  +
  +    public int getErrorCount() {
  +        return errorCount;
  +    }
  +
  +    public void setErrorCount(int errorCount) {
  +        this.errorCount = errorCount;
  +    }
   
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>