001: /**
002: *
003: */package clime.messadmin.model;
004:
005: import java.io.Serializable;
006: import java.util.Date;
007:
008: import clime.messadmin.model.stats.StatisticsAgregator;
009:
010: /**
011: * @author Cédrik LIME
012: */
013: public class RequestInfo implements Serializable {
014: protected String url;
015:
016: //protected volatile int hits = 0;//number of hits == usedTime.getHits()
017:
018: protected StatisticsAgregator requestLength = new StatisticsAgregator(
019: Long.MAX_VALUE, -1);//bytes
020: protected volatile long lastRequestDate = -1;// java.util.Date;
021: protected StatisticsAgregator responseLength = new StatisticsAgregator(
022: Long.MAX_VALUE, -1);//bytes
023: protected volatile long lastResponseDate = -1;// java.util.Date;
024:
025: protected StatisticsAgregator usedTime = new StatisticsAgregator(
026: Long.MAX_VALUE, -1);//milliseconds
027:
028: protected volatile int lastResponseStatus;
029: protected volatile int[] responseStatus = new int[6]; // 1xx to 5xx; 0 is for unset status
030:
031: protected volatile int nErrors = 0;
032: protected ErrorData lastError;
033:
034: /**
035: *
036: */
037: public RequestInfo(String url) {
038: super ();
039: this .url = url;
040: // for (int i = 0; i < responseStatus.length; ++i) {
041: // responseStatus[i] = new HitsCounter();
042: // }
043: }
044:
045: /**
046: * {@inheritDoc}
047: */
048: public String getURL() {
049: return url;
050: }
051:
052: /**
053: * {@inheritDoc}
054: */
055: public int getHits() {
056: return usedTime.getHits();
057: }
058:
059: /**
060: * {@inheritDoc}
061: */
062: public int getNErrors() {
063: return nErrors;
064: }
065:
066: /**
067: * {@inheritDoc}
068: */
069: public ErrorData getLastError() {
070: return lastError;
071: }
072:
073: /**
074: * {@inheritDoc}
075: */
076: public long getRequestLastLength() {
077: return requestLength.getLastValue();
078: }
079:
080: /**
081: * {@inheritDoc}
082: */
083: public long getResponseLastLength() {
084: return responseLength.getLastValue();
085: }
086:
087: /**
088: * {@inheritDoc}
089: */
090: public long getRequestMinLength() {
091: return requestLength.getMin();
092: }
093:
094: /**
095: * {@inheritDoc}
096: */
097: public long getResponseMinLength() {
098: return responseLength.getMin();
099: }
100:
101: /**
102: * {@inheritDoc}
103: */
104: public Date getRequestMinLengthDate() {
105: return requestLength.getMinAccessTime();
106: }
107:
108: /**
109: * {@inheritDoc}
110: */
111: public Date getResponseMinLengthDate() {
112: return responseLength.getMinAccessTime();
113: }
114:
115: /**
116: * {@inheritDoc}
117: */
118: public long getRequestMaxLength() {
119: return requestLength.getMax();
120: }
121:
122: /**
123: * {@inheritDoc}
124: */
125: public long getResponseMaxLength() {
126: return responseLength.getMax();
127: }
128:
129: /**
130: * {@inheritDoc}
131: */
132: public Date getRequestMaxLengthDate() {
133: return requestLength.getMaxAccessTime();
134: }
135:
136: /**
137: * {@inheritDoc}
138: */
139: public Date getResponseMaxLengthDate() {
140: return responseLength.getMaxAccessTime();
141: }
142:
143: /**
144: * {@inheritDoc}
145: */
146: public long getRequestTotalLength() {
147: return (long) requestLength.getTotal();
148: }
149:
150: /**
151: * {@inheritDoc}
152: */
153: public long getResponseTotalLength() {
154: return (long) responseLength.getTotal();
155: }
156:
157: /**
158: * {@inheritDoc}
159: */
160: public double getRequestMeanLength() {
161: return requestLength.getAvg();
162: }
163:
164: /**
165: * {@inheritDoc}
166: */
167: public double getResponseMeanLength() {
168: return responseLength.getAvg();
169: }
170:
171: /**
172: * {@inheritDoc}
173: */
174: public double getRequestStdDevLength() {
175: return requestLength.getStdDev();
176: }
177:
178: /**
179: * {@inheritDoc}
180: */
181: public double getResponseStdDevLength() {
182: return responseLength.getStdDev();
183: }
184:
185: /**
186: * {@inheritDoc}
187: */
188: public Date getLastRequestDate() {
189: return new Date(lastRequestDate); //requestLength.getLastAccessTime();
190: }
191:
192: /**
193: * {@inheritDoc}
194: */
195: public Date getLastResponseDate() {
196: return new Date(lastResponseDate); //responseLength.getLastAccessTime();
197: }
198:
199: /**
200: * {@inheritDoc}
201: */
202: public int getLastResponseStatus() {
203: return lastResponseStatus;
204: }
205:
206: /**
207: * {@inheritDoc}
208: */
209: public long getLastUsedTime() {
210: return usedTime.getLastValue();
211: }
212:
213: /**
214: * {@inheritDoc}
215: */
216: public long getMinUsedTime() {
217: return usedTime.getMin();
218: }
219:
220: /**
221: * {@inheritDoc}
222: */
223: public Date getMinUsedTimeDate() {
224: return usedTime.getMinAccessTime();
225: }
226:
227: /**
228: * {@inheritDoc}
229: */
230: public long getMaxUsedTime() {
231: return usedTime.getMax();
232: }
233:
234: /**
235: * {@inheritDoc}
236: */
237: public Date getMaxUsedTimeDate() {
238: return usedTime.getMaxAccessTime();
239: }
240:
241: /**
242: * {@inheritDoc}
243: */
244: public long getTotalUsedTime() {
245: return (long) usedTime.getTotal();
246: }
247:
248: /**
249: * {@inheritDoc}
250: */
251: public double getMeanUsedTime() {
252: return usedTime.getAvg();
253: }
254:
255: /**
256: * {@inheritDoc}
257: */
258: public double getStdDevUsedTime() {
259: return usedTime.getStdDev();
260: }
261: }
|