1
14
15 package com.liferay.portal.monitoring.statistics.portlet;
16
17 import com.liferay.portal.monitoring.MonitoringException;
18 import com.liferay.portal.monitoring.statistics.RequestStatistics;
19
20 import java.util.Set;
21
22
29 public class EventRequestSummaryStatistics implements PortletSummaryStatistics {
30
31 public long getAverageTime() {
32 long averageTime = 0;
33
34 long count = 0;
35
36 for (CompanyStatistics companyStatistics :
37 _serverStatistics.getCompanyStatisticsSet()) {
38
39 for (RequestStatistics requestStatistics :
40 companyStatistics.getEventRequestStatisticsSet()) {
41
42 averageTime += requestStatistics.getAverageTime();
43
44 count++;
45 }
46 }
47
48 return averageTime / count;
49 }
50
51 public long getAverageTimeByCompany(long companyId)
52 throws MonitoringException {
53
54 CompanyStatistics companyStatistics =
55 _serverStatistics.getCompanyStatistics(companyId);
56
57 return getAverageTimeByCompany(companyStatistics);
58 }
59
60 public long getAverageTimeByCompany(String webId)
61 throws MonitoringException {
62
63 CompanyStatistics companyStatistics =
64 _serverStatistics.getCompanyStatistics(webId);
65
66 return getAverageTimeByCompany(companyStatistics);
67 }
68
69 public long getAverageTimeByPortlet(String portletId)
70 throws MonitoringException {
71
72 long averageTime = 0;
73
74 Set<CompanyStatistics> companyStatisticsSet =
75 _serverStatistics.getCompanyStatisticsSet();
76
77 for (CompanyStatistics companyStatistics : companyStatisticsSet) {
78 RequestStatistics requestStatistics =
79 companyStatistics.getEventRequestStatistics(portletId);
80
81 averageTime += requestStatistics.getAverageTime();
82 }
83
84 return averageTime / companyStatisticsSet.size();
85 }
86
87 public long getAverageTimeByPortlet(String portletId, long companyId)
88 throws MonitoringException {
89
90 CompanyStatistics companyStatistics =
91 _serverStatistics.getCompanyStatistics(companyId);
92
93 RequestStatistics requestStatistics =
94 companyStatistics.getEventRequestStatistics(portletId);
95
96 return requestStatistics.getAverageTime();
97 }
98
99 public long getAverageTimeByPortlet(String portletId, String webId)
100 throws MonitoringException {
101
102 CompanyStatistics companyStatistics =
103 _serverStatistics.getCompanyStatistics(webId);
104
105 RequestStatistics requestStatistics =
106 companyStatistics.getEventRequestStatistics(portletId);
107
108 return requestStatistics.getAverageTime();
109 }
110
111 public long getErrorCount() {
112 long errorCount = 0;
113
114 for (CompanyStatistics companyStatistics :
115 _serverStatistics.getCompanyStatisticsSet()) {
116
117 errorCount += getErrorCountByCompany(companyStatistics);
118 }
119
120 return errorCount;
121 }
122
123 public long getErrorCountByCompany(long companyId)
124 throws MonitoringException {
125
126 CompanyStatistics companyStatistics =
127 _serverStatistics.getCompanyStatistics(companyId);
128
129 return getErrorCountByCompany(companyStatistics);
130 }
131
132 public long getErrorCountByCompany(String webId)
133 throws MonitoringException {
134
135 CompanyStatistics companyStatistics =
136 _serverStatistics.getCompanyStatistics(webId);
137
138 return getErrorCountByCompany(companyStatistics);
139 }
140
141 public long getErrorCountByPortlet(String portletId)
142 throws MonitoringException {
143
144 long errorCount = 0;
145
146 for (CompanyStatistics companyStatistics :
147 _serverStatistics.getCompanyStatisticsSet()) {
148
149 errorCount += getErrorCountByPortlet(portletId, companyStatistics);
150 }
151
152 return errorCount;
153 }
154
155 public long getErrorCountByPortlet(String portletId, long companyId)
156 throws MonitoringException {
157
158 CompanyStatistics companyStatistics =
159 _serverStatistics.getCompanyStatistics(companyId);
160
161 return getErrorCountByPortlet(portletId, companyStatistics);
162 }
163
164 public long getErrorCountByPortlet(String portletId, String webId)
165 throws MonitoringException {
166
167 CompanyStatistics companyStatistics =
168 _serverStatistics.getCompanyStatistics(webId);
169
170 return getErrorCountByPortlet(portletId, companyStatistics);
171 }
172
173 public long getMaxTime() {
174 long maxTime = 0;
175
176 for (CompanyStatistics companyStatistics :
177 _serverStatistics.getCompanyStatisticsSet()) {
178
179 for (RequestStatistics requestStatistics :
180 companyStatistics.getEventRequestStatisticsSet()) {
181
182 if (requestStatistics.getMaxTime() > maxTime) {
183 maxTime = requestStatistics.getMaxTime();
184 }
185 }
186 }
187
188 return maxTime;
189 }
190
191 public long getMaxTimeByCompany(long companyId) throws MonitoringException {
192 CompanyStatistics companyStatistics =
193 _serverStatistics.getCompanyStatistics(companyId);
194
195 return companyStatistics.getMaxTime();
196 }
197
198 public long getMaxTimeByCompany(String webId) throws MonitoringException {
199 CompanyStatistics companyStatistics =
200 _serverStatistics.getCompanyStatistics(webId);
201
202 return companyStatistics.getMaxTime();
203 }
204
205 public long getMaxTimeByPortlet(String portletId)
206 throws MonitoringException {
207
208 long maxTime = 0;
209
210 for (CompanyStatistics companyStatistics :
211 _serverStatistics.getCompanyStatisticsSet()) {
212
213 long curMaxTime = getMaxTimeByPortlet(portletId, companyStatistics);
214
215 if (curMaxTime > maxTime) {
216 maxTime = curMaxTime;
217 }
218 }
219
220 return maxTime;
221 }
222
223 public long getMaxTimeByPortlet(String portletId, long companyId)
224 throws MonitoringException {
225
226 CompanyStatistics companyStatistics =
227 _serverStatistics.getCompanyStatistics(companyId);
228
229 return getMaxTimeByPortlet(portletId, companyStatistics);
230 }
231
232 public long getMaxTimeByPortlet(String portletId, String webId)
233 throws MonitoringException {
234
235 CompanyStatistics companyStatistics =
236 _serverStatistics.getCompanyStatistics(webId);
237
238 return getMaxTimeByPortlet(portletId, companyStatistics);
239 }
240
241 public long getMinTime() {
242 long minTime = 0;
243
244 for (CompanyStatistics companyStatistics :
245 _serverStatistics.getCompanyStatisticsSet()) {
246
247 for (RequestStatistics requestStatistics :
248 companyStatistics.getEventRequestStatisticsSet()) {
249
250 if (requestStatistics.getMinTime() < minTime) {
251 minTime = requestStatistics.getMinTime();
252 }
253 }
254 }
255
256 return minTime;
257 }
258
259 public long getMinTimeByCompany(long companyId) throws MonitoringException {
260 CompanyStatistics companyStatistics =
261 _serverStatistics.getCompanyStatistics(companyId);
262
263 return companyStatistics.getMinTime();
264 }
265
266 public long getMinTimeByCompany(String webId) throws MonitoringException {
267 CompanyStatistics companyStatistics =
268 _serverStatistics.getCompanyStatistics(webId);
269
270 return companyStatistics.getMinTime();
271 }
272
273 public long getMinTimeByPortlet(String portletId)
274 throws MonitoringException {
275
276 long minTime = 0;
277
278 for (CompanyStatistics companyStatistics :
279 _serverStatistics.getCompanyStatisticsSet()) {
280
281 long curMinTime = getMinTimeByPortlet(portletId, companyStatistics);
282
283 if (curMinTime < minTime) {
284 minTime = curMinTime;
285 }
286 }
287
288 return minTime;
289 }
290
291 public long getMinTimeByPortlet(String portletId, long companyId)
292 throws MonitoringException {
293
294 CompanyStatistics companyStatistics =
295 _serverStatistics.getCompanyStatistics(companyId);
296
297 return getMinTimeByPortlet(portletId, companyStatistics);
298 }
299
300 public long getMinTimeByPortlet(String portletId, String webId)
301 throws MonitoringException {
302
303 CompanyStatistics companyStatistics =
304 _serverStatistics.getCompanyStatistics(webId);
305
306 return getMinTimeByPortlet(portletId, companyStatistics);
307 }
308
309 public long getRequestCount() {
310 long requestCount = 0;
311
312 for (CompanyStatistics companyStatistics :
313 _serverStatistics.getCompanyStatisticsSet()) {
314
315 requestCount += getRequestCountByCompany(companyStatistics);
316 }
317
318 return requestCount;
319 }
320
321 public long getRequestCountByCompany(long companyId)
322 throws MonitoringException {
323
324 CompanyStatistics companyStatistics =
325 _serverStatistics.getCompanyStatistics(companyId);
326
327 return getRequestCountByCompany(companyStatistics);
328 }
329
330 public long getRequestCountByCompany(String webId)
331 throws MonitoringException {
332
333 CompanyStatistics companyStatistics =
334 _serverStatistics.getCompanyStatistics(webId);
335
336 return getRequestCountByCompany(companyStatistics);
337 }
338
339 public long getRequestCountByPortlet(String portletId)
340 throws MonitoringException {
341
342 long requestCount = 0;
343
344 for (CompanyStatistics companyStatistics :
345 _serverStatistics.getCompanyStatisticsSet()) {
346
347 requestCount += getRequestCountByPortlet(
348 portletId, companyStatistics);
349 }
350
351 return requestCount;
352 }
353
354 public long getRequestCountByPortlet(String portletId, long companyId)
355 throws MonitoringException {
356
357 CompanyStatistics companyStatistics =
358 _serverStatistics.getCompanyStatistics(companyId);
359
360 return getRequestCountByPortlet(portletId, companyStatistics);
361 }
362
363 public long getRequestCountByPortlet(String portletId, String webId)
364 throws MonitoringException {
365
366 CompanyStatistics companyStatistics =
367 _serverStatistics.getCompanyStatistics(webId);
368
369 return getRequestCountByPortlet(portletId, companyStatistics);
370 }
371
372 public long getSuccessCount() {
373 long successCount = 0;
374
375 for (CompanyStatistics companyStatistics :
376 _serverStatistics.getCompanyStatisticsSet()) {
377
378 successCount += getSuccessCountByCompany(companyStatistics);
379 }
380
381 return successCount;
382 }
383
384 public long getSuccessCountByCompany(long companyId)
385 throws MonitoringException {
386
387 CompanyStatistics companyStatistics =
388 _serverStatistics.getCompanyStatistics(companyId);
389
390 return getSuccessCountByCompany(companyStatistics);
391 }
392
393 public long getSuccessCountByCompany(String webId)
394 throws MonitoringException {
395
396 CompanyStatistics companyStatistics =
397 _serverStatistics.getCompanyStatistics(webId);
398
399 return getSuccessCountByCompany(companyStatistics);
400 }
401
402 public long getSuccessCountByPortlet(String portletId)
403 throws MonitoringException {
404
405 long successCount = 0;
406
407 for (CompanyStatistics companyStatistics :
408 _serverStatistics.getCompanyStatisticsSet()) {
409
410 successCount += getSuccessCountByPortlet(
411 portletId, companyStatistics);
412 }
413
414 return successCount;
415 }
416
417 public long getSuccessCountByPortlet(String portletId, long companyId)
418 throws MonitoringException {
419
420 CompanyStatistics companyStatistics =
421 _serverStatistics.getCompanyStatistics(companyId);
422
423 return getSuccessCountByPortlet(portletId, companyStatistics);
424 }
425
426 public long getSuccessCountByPortlet(String portletId, String webId)
427 throws MonitoringException {
428
429 CompanyStatistics companyStatistics =
430 _serverStatistics.getCompanyStatistics(webId);
431
432 return getSuccessCountByPortlet(portletId, companyStatistics);
433 }
434
435 public long getTimeoutCount() {
436 long timeoutCount = 0;
437
438 for (CompanyStatistics companyStatistics :
439 _serverStatistics.getCompanyStatisticsSet()) {
440
441 timeoutCount += getTimeoutCountByCompany(companyStatistics);
442 }
443
444 return timeoutCount;
445 }
446
447 public long getTimeoutCountByCompany(long companyId)
448 throws MonitoringException {
449
450 CompanyStatistics companyStatistics =
451 _serverStatistics.getCompanyStatistics(companyId);
452
453 return getTimeoutCountByCompany(companyStatistics);
454 }
455
456 public long getTimeoutCountByCompany(String webId)
457 throws MonitoringException {
458
459 CompanyStatistics companyStatistics =
460 _serverStatistics.getCompanyStatistics(webId);
461
462 return getTimeoutCountByCompany(companyStatistics);
463 }
464
465 public long getTimeoutCountByPortlet(String portletId)
466 throws MonitoringException {
467
468 long timeoutCount = 0;
469
470 for (CompanyStatistics companyStatistics :
471 _serverStatistics.getCompanyStatisticsSet()) {
472
473 timeoutCount += getTimeoutCountByPortlet(
474 portletId, companyStatistics);
475 }
476
477 return timeoutCount;
478 }
479
480 public long getTimeoutCountByPortlet(String portletId, long companyId)
481 throws MonitoringException {
482
483 CompanyStatistics companyStatistics =
484 _serverStatistics.getCompanyStatistics(companyId);
485
486 return getTimeoutCountByPortlet(portletId, companyStatistics);
487 }
488
489 public long getTimeoutCountByPortlet(String portletId, String webId)
490 throws MonitoringException {
491
492 CompanyStatistics companyStatistics =
493 _serverStatistics.getCompanyStatistics(webId);
494
495 return getTimeoutCountByPortlet(portletId, companyStatistics);
496 }
497
498 public void setServerStatistics(ServerStatistics serverStatistics) {
499 _serverStatistics = serverStatistics;
500 }
501
502 protected long getAverageTimeByCompany(
503 CompanyStatistics companyStatistics) {
504
505 long averageTime = 0;
506
507 Set<RequestStatistics> requestStatisticsSet =
508 companyStatistics.getEventRequestStatisticsSet();
509
510 for (RequestStatistics requestStatistics : requestStatisticsSet) {
511 averageTime += requestStatistics.getAverageTime();
512 }
513
514 return averageTime / requestStatisticsSet.size();
515 }
516
517 protected long getErrorCountByCompany(CompanyStatistics companyStatistics) {
518 long errorCount = 0;
519
520 for (RequestStatistics requestStatistics :
521 companyStatistics.getEventRequestStatisticsSet()) {
522
523 errorCount += requestStatistics.getErrorCount();
524 }
525
526 return errorCount;
527 }
528
529 protected long getErrorCountByPortlet(
530 String portletId, CompanyStatistics companyStatistics)
531 throws MonitoringException {
532
533 RequestStatistics requestStatistics =
534 companyStatistics.getEventRequestStatistics(portletId);
535
536 return requestStatistics.getErrorCount();
537 }
538
539 protected long getMaxTimeByPortlet(
540 String portletId, CompanyStatistics companyStatistics)
541 throws MonitoringException {
542
543 long maxTime = 0;
544
545 RequestStatistics requestStatistics =
546 companyStatistics.getEventRequestStatistics(portletId);
547
548 if (requestStatistics.getMaxTime() > maxTime) {
549 maxTime = requestStatistics.getMaxTime();
550 }
551
552 return maxTime;
553 }
554
555 protected long getMinTimeByPortlet(
556 String portletId, CompanyStatistics companyStatistics)
557 throws MonitoringException {
558
559 long minTime = 0;
560
561 RequestStatistics requestStatistics =
562 companyStatistics.getEventRequestStatistics(portletId);
563
564 if (requestStatistics.getMinTime() < minTime) {
565 minTime = requestStatistics.getMinTime();
566 }
567
568 return minTime;
569 }
570
571 protected long getRequestCountByCompany(
572 CompanyStatistics companyStatistics) {
573
574 long requestCount = 0;
575
576 for (RequestStatistics requestStatistics :
577 companyStatistics.getEventRequestStatisticsSet()) {
578
579 requestCount += requestStatistics.getRequestCount();
580 }
581
582 return requestCount;
583 }
584
585 protected long getRequestCountByPortlet(
586 String portletId, CompanyStatistics companyStatistics)
587 throws MonitoringException {
588
589 RequestStatistics requestStatistics =
590 companyStatistics.getEventRequestStatistics(portletId);
591
592 return requestStatistics.getRequestCount();
593 }
594
595 protected long getSuccessCountByCompany(
596 CompanyStatistics companyStatistics) {
597
598 long successCount = 0;
599
600 for (RequestStatistics requestStatistics :
601 companyStatistics.getEventRequestStatisticsSet()) {
602
603 successCount += requestStatistics.getSuccessCount();
604 }
605
606 return successCount;
607 }
608
609 protected long getSuccessCountByPortlet(
610 String portletId, CompanyStatistics companyStatistics)
611 throws MonitoringException {
612
613 RequestStatistics requestStatistics =
614 companyStatistics.getEventRequestStatistics(portletId);
615
616 return requestStatistics.getSuccessCount();
617 }
618
619 protected long getTimeoutCountByCompany(
620 CompanyStatistics companyStatistics) {
621
622 long timeoutCount = 0;
623
624 for (RequestStatistics requestStatistics :
625 companyStatistics.getEventRequestStatisticsSet()) {
626
627 timeoutCount += requestStatistics.getTimeoutCount();
628 }
629
630 return timeoutCount;
631 }
632
633 protected long getTimeoutCountByPortlet(
634 String portletId, CompanyStatistics companyStatistics)
635 throws MonitoringException {
636
637 RequestStatistics requestStatistics =
638 companyStatistics.getEventRequestStatistics(portletId);
639
640 return requestStatistics.getTimeoutCount();
641 }
642
643 private ServerStatistics _serverStatistics;
644
645 }