@@ -67,7 +67,7 @@ public class Statistics {
67
67
/**
68
68
* Adds a single request into all requests.
69
69
*/
70
- public void addRequest (HttpServletRequest req ) {
70
+ synchronized public void addRequest (HttpServletRequest req ) {
71
71
maybeRefresh ();
72
72
73
73
requestsPerMinute ++;
@@ -87,7 +87,7 @@ public void addRequest(HttpServletRequest req) {
87
87
/**
88
88
* Refreshes the last timestamp and number of minutes since start if needed.
89
89
*/
90
- protected void maybeRefresh () {
90
+ synchronized protected void maybeRefresh () {
91
91
if (timeStart + 60 * 1000 <= System .currentTimeMillis ()) {
92
92
// several minutes have passed
93
93
minutes += (System .currentTimeMillis () - timeStart ) / (60 * 1000 );
@@ -102,7 +102,7 @@ protected void maybeRefresh() {
102
102
* @param req the given request
103
103
* @param category category
104
104
*/
105
- public void addRequest (HttpServletRequest req , String category ) {
105
+ synchronized public void addRequest (HttpServletRequest req , String category ) {
106
106
Long val = requestCategories .get (category );
107
107
if (val == null ) {
108
108
val = new Long (0 );
@@ -118,7 +118,7 @@ public void addRequest(HttpServletRequest req, String category) {
118
118
* @param category category
119
119
* @param v time spent on processing this request
120
120
*/
121
- public void addRequestTime (HttpServletRequest req , String category , long v ) {
121
+ synchronized public void addRequestTime (HttpServletRequest req , String category , long v ) {
122
122
addRequest (req , category );
123
123
Long val = timing .get (category );
124
124
Long min = timingMin .get (category );
@@ -172,35 +172,35 @@ public Map<String, Double> getTimingAvg() {
172
172
return timingAvg ;
173
173
}
174
174
175
- public void setRequestCategories (Map <String , Long > requestCategories ) {
175
+ synchronized public void setRequestCategories (Map <String , Long > requestCategories ) {
176
176
this .requestCategories = requestCategories ;
177
177
}
178
178
179
- public void setTiming (Map <String , Long > timing ) {
179
+ synchronized public void setTiming (Map <String , Long > timing ) {
180
180
this .timing = timing ;
181
181
}
182
182
183
- public void setTimingMin (Map <String , Long > timing_min ) {
183
+ synchronized public void setTimingMin (Map <String , Long > timing_min ) {
184
184
this .timingMin = timing_min ;
185
185
}
186
186
187
- public void setTimingMax (Map <String , Long > timing_max ) {
187
+ synchronized public void setTimingMax (Map <String , Long > timing_max ) {
188
188
this .timingMax = timing_max ;
189
189
}
190
190
191
191
public long getTimeStart () {
192
192
return timeStart ;
193
193
}
194
194
195
- public void setTimeStart (long timeStart ) {
195
+ synchronized public void setTimeStart (long timeStart ) {
196
196
this .timeStart = timeStart ;
197
197
}
198
198
199
199
public long getRequests () {
200
200
return requests ;
201
201
}
202
202
203
- public void setRequests (long requests ) {
203
+ synchronized public void setRequests (long requests ) {
204
204
this .requests = requests ;
205
205
}
206
206
@@ -209,7 +209,7 @@ public long getMinutes() {
209
209
return minutes ;
210
210
}
211
211
212
- public void setMinutes (long minutes ) {
212
+ synchronized public void setMinutes (long minutes ) {
213
213
this .minutes = minutes ;
214
214
}
215
215
@@ -218,7 +218,7 @@ public long getRequestsPerMinute() {
218
218
return requestsPerMinute ;
219
219
}
220
220
221
- public void setRequestsPerMinute (long requestsPerMinute ) {
221
+ synchronized public void setRequestsPerMinute (long requestsPerMinute ) {
222
222
this .requestsPerMinute = requestsPerMinute ;
223
223
}
224
224
@@ -229,7 +229,7 @@ public long getRequestsPerMinuteMin() {
229
229
return requestsPerMinuteMin ;
230
230
}
231
231
232
- public void setRequestsPerMinuteMin (long requestsPerMinuteMin ) {
232
+ synchronized public void setRequestsPerMinuteMin (long requestsPerMinuteMin ) {
233
233
this .requestsPerMinuteMin = requestsPerMinuteMin ;
234
234
}
235
235
@@ -240,7 +240,7 @@ public long getRequestsPerMinuteMax() {
240
240
return requestsPerMinuteMax ;
241
241
}
242
242
243
- public void setRequestsPerMinuteMax (long requestsPerMinuteMax ) {
243
+ synchronized public void setRequestsPerMinuteMax (long requestsPerMinuteMax ) {
244
244
this .requestsPerMinuteMax = requestsPerMinuteMax ;
245
245
}
246
246
@@ -253,15 +253,15 @@ public long[] getDayHistogram() {
253
253
return dayHistogram ;
254
254
}
255
255
256
- public void setDayHistogram (long [] dayHistogram ) {
256
+ synchronized public void setDayHistogram (long [] dayHistogram ) {
257
257
this .dayHistogram = dayHistogram ;
258
258
}
259
259
260
260
public long [] getMonthHistogram () {
261
261
return monthHistogram ;
262
262
}
263
263
264
- public void setMonthHistogram (long [] monthHistogram ) {
264
+ synchronized public void setMonthHistogram (long [] monthHistogram ) {
265
265
this .monthHistogram = monthHistogram ;
266
266
}
267
267
0 commit comments