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