1
14
15 package com.liferay.portal.monitoring.statistics;
16
17
23 public class RequestStatistics implements Statistics {
24
25 public RequestStatistics(String name) {
26 _name = name;
27 _errorStatistics = new CountStatistics(name);
28 _successStatistics = new AverageStatistics(name);
29 _timeoutStatistics = new CountStatistics(name);
30 }
31
32 public long getAverageTime() {
33 return _successStatistics.getAverageTime();
34 }
35
36 public String getDescription() {
37 return _description;
38 }
39
40 public long getErrorCount() {
41 return _errorStatistics.getCount();
42 }
43
44 public long getMaxTime() {
45 return _successStatistics.getMaxTime();
46 }
47
48 public long getMinTime() {
49 return _successStatistics.getMinTime();
50 }
51
52 public String getName() {
53 return _name;
54 }
55
56 public long getRequestCount() {
57 return getErrorCount() + getSuccessCount() + getTimeoutCount();
58 }
59
60 public long getSuccessCount() {
61 return _successStatistics.getCount();
62 }
63
64 public long getTimeoutCount() {
65 return _timeoutStatistics.getCount();
66 }
67
68 public void incrementError() {
69 _errorStatistics.incrementCount();
70 }
71
72 public void incrementSuccessDuration(long duration) {
73 _successStatistics.addDuration(duration);
74 }
75
76 public void incrementTimeout() {
77 _timeoutStatistics.incrementCount();
78 }
79
80 public void reset() {
81 _errorStatistics.reset();
82 _successStatistics.reset();
83 _timeoutStatistics.reset();
84 }
85
86 public void setDescription(String description) {
87 _description = description;
88 }
89
90 private String _description;
91 private CountStatistics _errorStatistics;
92 private String _name;
93 private AverageStatistics _successStatistics;
94 private CountStatistics _timeoutStatistics;
95
96 }