View Javadoc

1   package net.sf.appstatus.services;
2   
3   public class CachedCallStatistics {
4   
5   	private CallStatistics direct;
6   	private CallStatistics cache;
7   
8   	public CachedCallStatistics(int minMaxDelay) {
9   		direct = new CallStatistics(minMaxDelay);
10  		cache = new CallStatistics(minMaxDelay);
11  	}
12  
13  	public void addCall(Long executionTime, boolean cacheHit, boolean failure, boolean error, int nestedCalls) {
14  
15  		// Update statistics
16  		if (cacheHit) {
17  			cache.addCall(executionTime, failure, error, nestedCalls);
18  		} else {
19  			direct.addCall(executionTime, failure, error, nestedCalls);
20  		}
21  
22  	}
23  
24  	public CallStatistics getCacheStatistics() {
25  		return cache;
26  	}
27  
28  	public CallStatistics getDirectStatistics() {
29  		return direct;
30  	}
31  
32  	public long getFailures() {
33  		return direct.getFailures() + cache.getFailures();
34  	}
35  
36  	public long getErrors() {
37  		return direct.getErrors() + cache.getErrors();
38  	}
39  
40  	public long getTotalHits() {
41  		return direct.getHits() + cache.getHits();
42  	}
43  
44  }