001
014
015 package com.liferay.portal.monitoring.statistics;
016
017
021 public class RequestStatistics implements Statistics {
022
023 public RequestStatistics(String name) {
024 _name = name;
025 _errorStatistics = new CountStatistics(name);
026 _successStatistics = new AverageStatistics(name);
027 _timeoutStatistics = new CountStatistics(name);
028 }
029
030 public long getAverageTime() {
031 return _successStatistics.getAverageTime();
032 }
033
034 public String getDescription() {
035 return _description;
036 }
037
038 public long getErrorCount() {
039 return _errorStatistics.getCount();
040 }
041
042 public long getMaxTime() {
043 return _successStatistics.getMaxTime();
044 }
045
046 public long getMinTime() {
047 return _successStatistics.getMinTime();
048 }
049
050 public String getName() {
051 return _name;
052 }
053
054 public long getRequestCount() {
055 return getErrorCount() + getSuccessCount() + getTimeoutCount();
056 }
057
058 public long getSuccessCount() {
059 return _successStatistics.getCount();
060 }
061
062 public long getTimeoutCount() {
063 return _timeoutStatistics.getCount();
064 }
065
066 public void incrementError() {
067 _errorStatistics.incrementCount();
068 }
069
070 public void incrementSuccessDuration(long duration) {
071 _successStatistics.addDuration(duration);
072 }
073
074 public void incrementTimeout() {
075 _timeoutStatistics.incrementCount();
076 }
077
078 public void reset() {
079 _errorStatistics.reset();
080 _successStatistics.reset();
081 _timeoutStatistics.reset();
082 }
083
084 public void setDescription(String description) {
085 _description = description;
086 }
087
088 private String _description;
089 private CountStatistics _errorStatistics;
090 private String _name;
091 private AverageStatistics _successStatistics;
092 private CountStatistics _timeoutStatistics;
093
094 }