KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > monitor > RequestMonitorData


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.container.monitor;
6 /*
7  * Tue, May 27, 2003 @
8  * @author: Tuan Nguyen
9  * @version: $Id: RequestMonitorData.java,v 1.3 2004/05/05 21:28:44 tuan08 Exp $
10  * @since: 0.0
11  * @email: tuan08@yahoo.com
12  */

13 public class RequestMonitorData {
14   private long minRange_ ;
15   private long maxRange_ ;
16   private int requestCounter_ ;
17   private long minExecutionTime_ ;
18   private long maxExecutionTime_ ;
19   private long sumExecutionTime_ = 0 ;
20   
21   public RequestMonitorData(long minRange, long maxRange) {
22     requestCounter_ = 0 ;
23     minExecutionTime_ = 0 ;
24     maxExecutionTime_ = 0 ;
25     minRange_ = minRange ;
26     maxRange_ = maxRange ;
27   }
28
29   public long minRange() { return minRange_ ; }
30   public long maxRange() { return maxRange_ ; }
31
32   public int getRequestCounter() { return requestCounter_ ; }
33
34   public long minExecutionTime() { return minExecutionTime_ ; }
35
36   public long maxExecutionTime() { return maxExecutionTime_ ; }
37
38   public long averageExecutionTime() {
39     if(requestCounter_ <= 0) return 0 ;
40     return sumExecutionTime_/requestCounter_ ;
41   }
42
43   public long sumExecutionTime() { return sumExecutionTime_ ; }
44   
45   public void logRequest(long startTime, long endTime) {
46     requestCounter_++ ;
47     if(requestCounter_ > 0) {
48       long executionTime = endTime - startTime ;
49       sumExecutionTime_ += executionTime;
50       if(executionTime < minExecutionTime_) minExecutionTime_ = executionTime ;
51       if(executionTime > maxExecutionTime_) maxExecutionTime_ = executionTime ;
52     }
53   }
54
55   public void logRequest(long executionTime) {
56     requestCounter_++ ;
57     if(requestCounter_ > 0) {
58       sumExecutionTime_ += executionTime;
59       if(executionTime < minExecutionTime_) minExecutionTime_ = executionTime ;
60       if(executionTime > maxExecutionTime_) maxExecutionTime_ = executionTime ;
61     }
62   }
63 }
64
Popular Tags