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 EventRequestSummaryStatistics(ServerStatistics serverStatistics) {
40 _serverStatistics = serverStatistics;
41 }
42
43 public long getAverageTime() {
44 long averageTime = 0;
45
46 long count = 0;
47
48 for (CompanyStatistics companyStatistics :
49 _serverStatistics.getCompanyStatisticsSet()) {
50
51 for (RequestStatistics requestStatistics :
52 companyStatistics.getEventRequestStatisticsSet()) {
53
54 averageTime += requestStatistics.getAverageTime();
55
56 count++;
57 }
58 }
59
60 return averageTime / count;
61 }
62
63 public long getAverageTimeByCompany(long companyId)
64 throws MonitoringException {
65
66 CompanyStatistics companyStatistics =
67 _serverStatistics.getCompanyStatistics(companyId);
68
69 return getAverageTimeByCompany(companyStatistics);
70 }
71
72 public long getAverageTimeByCompany(String webId)
73 throws MonitoringException {
74
75 CompanyStatistics companyStatistics =
76 _serverStatistics.getCompanyStatistics(webId);
77
78 return getAverageTimeByCompany(companyStatistics);
79 }
80
81 public long getAverageTimeByPortlet(String portletId)
82 throws MonitoringException {
83
84 long averageTime = 0;
85
86 Set<CompanyStatistics> companyStatisticsSet =
87 _serverStatistics.getCompanyStatisticsSet();
88
89 for (CompanyStatistics companyStatistics : companyStatisticsSet) {
90 RequestStatistics requestStatistics =
91 companyStatistics.getEventRequestStatistics(portletId);
92
93 averageTime += requestStatistics.getAverageTime();
94 }
95
96 return averageTime / companyStatisticsSet.size();
97 }
98
99 public long getAverageTimeByPortlet(String portletId, long companyId)
100 throws MonitoringException {
101
102 CompanyStatistics companyStatistics =
103 _serverStatistics.getCompanyStatistics(companyId);
104
105 RequestStatistics requestStatistics =
106 companyStatistics.getEventRequestStatistics(portletId);
107
108 return requestStatistics.getAverageTime();
109 }
110
111 public long getAverageTimeByPortlet(String portletId, String webId)
112 throws MonitoringException {
113
114 CompanyStatistics companyStatistics =
115 _serverStatistics.getCompanyStatistics(webId);
116
117 RequestStatistics requestStatistics =
118 companyStatistics.getEventRequestStatistics(portletId);
119
120 return requestStatistics.getAverageTime();
121 }
122
123 public long getErrorCount() {
124 long errorCount = 0;
125
126 for (CompanyStatistics companyStatistics :
127 _serverStatistics.getCompanyStatisticsSet()) {
128
129 errorCount += getErrorCountByCompany(companyStatistics);
130 }
131
132 return errorCount;
133 }
134
135 public long getErrorCountByCompany(long companyId)
136 throws MonitoringException {
137
138 CompanyStatistics companyStatistics =
139 _serverStatistics.getCompanyStatistics(companyId);
140
141 return getErrorCountByCompany(companyStatistics);
142 }
143
144 public long getErrorCountByCompany(String webId)
145 throws MonitoringException {
146
147 CompanyStatistics companyStatistics =
148 _serverStatistics.getCompanyStatistics(webId);
149
150 return getErrorCountByCompany(companyStatistics);
151 }
152
153 public long getErrorCountByPortlet(String portletId)
154 throws MonitoringException {
155
156 long errorCount = 0;
157
158 for (CompanyStatistics companyStatistics :
159 _serverStatistics.getCompanyStatisticsSet()) {
160
161 errorCount += getErrorCountByPortlet(portletId, companyStatistics);
162 }
163
164 return errorCount;
165 }
166
167 public long getErrorCountByPortlet(String portletId, long companyId)
168 throws MonitoringException {
169
170 CompanyStatistics companyStatistics =
171 _serverStatistics.getCompanyStatistics(companyId);
172
173 return getErrorCountByPortlet(portletId, companyStatistics);
174 }
175
176 public long getErrorCountByPortlet(String portletId, String webId)
177 throws MonitoringException {
178
179 CompanyStatistics companyStatistics =
180 _serverStatistics.getCompanyStatistics(webId);
181
182 return getErrorCountByPortlet(portletId, companyStatistics);
183 }
184
185 public long getMaxTime() {
186 long maxTime = 0;
187
188 for (CompanyStatistics companyStatistics :
189 _serverStatistics.getCompanyStatisticsSet()) {
190
191 for (RequestStatistics requestStatistics :
192 companyStatistics.getEventRequestStatisticsSet()) {
193
194 if (requestStatistics.getMaxTime() > maxTime) {
195 maxTime = requestStatistics.getMaxTime();
196 }
197 }
198 }
199
200 return maxTime;
201 }
202
203 public long getMaxTimeByCompany(long companyId) throws MonitoringException {
204 CompanyStatistics companyStatistics =
205 _serverStatistics.getCompanyStatistics(companyId);
206
207 return companyStatistics.getMaxTime();
208 }
209
210 public long getMaxTimeByCompany(String webId) throws MonitoringException {
211 CompanyStatistics companyStatistics =
212 _serverStatistics.getCompanyStatistics(webId);
213
214 return companyStatistics.getMaxTime();
215 }
216
217 public long getMaxTimeByPortlet(String portletId)
218 throws MonitoringException {
219
220 long maxTime = 0;
221
222 for (CompanyStatistics companyStatistics :
223 _serverStatistics.getCompanyStatisticsSet()) {
224
225 long curMaxTime = getMaxTimeByPortlet(portletId, companyStatistics);
226
227 if (curMaxTime > maxTime) {
228 maxTime = curMaxTime;
229 }
230 }
231
232 return maxTime;
233 }
234
235 public long getMaxTimeByPortlet(String portletId, long companyId)
236 throws MonitoringException {
237
238 CompanyStatistics companyStatistics =
239 _serverStatistics.getCompanyStatistics(companyId);
240
241 return getMaxTimeByPortlet(portletId, companyStatistics);
242 }
243
244 public long getMaxTimeByPortlet(String portletId, String webId)
245 throws MonitoringException {
246
247 CompanyStatistics companyStatistics =
248 _serverStatistics.getCompanyStatistics(webId);
249
250 return getMaxTimeByPortlet(portletId, companyStatistics);
251 }
252
253 public long getMinTime() {
254 long minTime = 0;
255
256 for (CompanyStatistics companyStatistics :
257 _serverStatistics.getCompanyStatisticsSet()) {
258
259 for (RequestStatistics requestStatistics :
260 companyStatistics.getEventRequestStatisticsSet()) {
261
262 if (requestStatistics.getMinTime() < minTime) {
263 minTime = requestStatistics.getMinTime();
264 }
265 }
266 }
267
268 return minTime;
269 }
270
271 public long getMinTimeByCompany(long companyId) throws MonitoringException {
272 CompanyStatistics companyStatistics =
273 _serverStatistics.getCompanyStatistics(companyId);
274
275 return companyStatistics.getMinTime();
276 }
277
278 public long getMinTimeByCompany(String webId) throws MonitoringException {
279 CompanyStatistics companyStatistics =
280 _serverStatistics.getCompanyStatistics(webId);
281
282 return companyStatistics.getMinTime();
283 }
284
285 public long getMinTimeByPortlet(String portletId)
286 throws MonitoringException {
287
288 long minTime = 0;
289
290 for (CompanyStatistics companyStatistics :
291 _serverStatistics.getCompanyStatisticsSet()) {
292
293 long curMinTime = getMinTimeByPortlet(portletId, companyStatistics);
294
295 if (curMinTime < minTime) {
296 minTime = curMinTime;
297 }
298 }
299
300 return minTime;
301 }
302
303 public long getMinTimeByPortlet(String portletId, long companyId)
304 throws MonitoringException {
305
306 CompanyStatistics companyStatistics =
307 _serverStatistics.getCompanyStatistics(companyId);
308
309 return getMinTimeByPortlet(portletId, companyStatistics);
310 }
311
312 public long getMinTimeByPortlet(String portletId, String webId)
313 throws MonitoringException {
314
315 CompanyStatistics companyStatistics =
316 _serverStatistics.getCompanyStatistics(webId);
317
318 return getMinTimeByPortlet(portletId, companyStatistics);
319 }
320
321 public long getRequestCount() {
322 long requestCount = 0;
323
324 for (CompanyStatistics companyStatistics :
325 _serverStatistics.getCompanyStatisticsSet()) {
326
327 requestCount += getRequestCountByCompany(companyStatistics);
328 }
329
330 return requestCount;
331 }
332
333 public long getRequestCountByCompany(long companyId)
334 throws MonitoringException {
335
336 CompanyStatistics companyStatistics =
337 _serverStatistics.getCompanyStatistics(companyId);
338
339 return getRequestCountByCompany(companyStatistics);
340 }
341
342 public long getRequestCountByCompany(String webId)
343 throws MonitoringException {
344
345 CompanyStatistics companyStatistics =
346 _serverStatistics.getCompanyStatistics(webId);
347
348 return getRequestCountByCompany(companyStatistics);
349 }
350
351 public long getRequestCountByPortlet(String portletId)
352 throws MonitoringException {
353
354 long requestCount = 0;
355
356 for (CompanyStatistics companyStatistics :
357 _serverStatistics.getCompanyStatisticsSet()) {
358
359 requestCount += getRequestCountByPortlet(
360 portletId, companyStatistics);
361 }
362
363 return requestCount;
364 }
365
366 public long getRequestCountByPortlet(String portletId, long companyId)
367 throws MonitoringException {
368
369 CompanyStatistics companyStatistics =
370 _serverStatistics.getCompanyStatistics(companyId);
371
372 return getRequestCountByPortlet(portletId, companyStatistics);
373 }
374
375 public long getRequestCountByPortlet(String portletId, String webId)
376 throws MonitoringException {
377
378 CompanyStatistics companyStatistics =
379 _serverStatistics.getCompanyStatistics(webId);
380
381 return getRequestCountByPortlet(portletId, companyStatistics);
382 }
383
384 public long getSuccessCount() {
385 long successCount = 0;
386
387 for (CompanyStatistics companyStatistics :
388 _serverStatistics.getCompanyStatisticsSet()) {
389
390 successCount += getSuccessCountByCompany(companyStatistics);
391 }
392
393 return successCount;
394 }
395
396 public long getSuccessCountByCompany(long companyId)
397 throws MonitoringException {
398
399 CompanyStatistics companyStatistics =
400 _serverStatistics.getCompanyStatistics(companyId);
401
402 return getSuccessCountByCompany(companyStatistics);
403 }
404
405 public long getSuccessCountByCompany(String webId)
406 throws MonitoringException {
407
408 CompanyStatistics companyStatistics =
409 _serverStatistics.getCompanyStatistics(webId);
410
411 return getSuccessCountByCompany(companyStatistics);
412 }
413
414 public long getSuccessCountByPortlet(String portletId)
415 throws MonitoringException {
416
417 long successCount = 0;
418
419 for (CompanyStatistics companyStatistics :
420 _serverStatistics.getCompanyStatisticsSet()) {
421
422 successCount += getSuccessCountByPortlet(
423 portletId, companyStatistics);
424 }
425
426 return successCount;
427 }
428
429 public long getSuccessCountByPortlet(String portletId, long companyId)
430 throws MonitoringException {
431
432 CompanyStatistics companyStatistics =
433 _serverStatistics.getCompanyStatistics(companyId);
434
435 return getSuccessCountByPortlet(portletId, companyStatistics);
436 }
437
438 public long getSuccessCountByPortlet(String portletId, String webId)
439 throws MonitoringException {
440
441 CompanyStatistics companyStatistics =
442 _serverStatistics.getCompanyStatistics(webId);
443
444 return getSuccessCountByPortlet(portletId, companyStatistics);
445 }
446
447 public long getTimeoutCount() {
448 long timeoutCount = 0;
449
450 for (CompanyStatistics companyStatistics :
451 _serverStatistics.getCompanyStatisticsSet()) {
452
453 timeoutCount += getTimeoutCountByCompany(companyStatistics);
454 }
455
456 return timeoutCount;
457 }
458
459 public long getTimeoutCountByCompany(long companyId)
460 throws MonitoringException {
461
462 CompanyStatistics companyStatistics =
463 _serverStatistics.getCompanyStatistics(companyId);
464
465 return getTimeoutCountByCompany(companyStatistics);
466 }
467
468 public long getTimeoutCountByCompany(String webId)
469 throws MonitoringException {
470
471 CompanyStatistics companyStatistics =
472 _serverStatistics.getCompanyStatistics(webId);
473
474 return getTimeoutCountByCompany(companyStatistics);
475 }
476
477 public long getTimeoutCountByPortlet(String portletId)
478 throws MonitoringException {
479
480 long timeoutCount = 0;
481
482 for (CompanyStatistics companyStatistics :
483 _serverStatistics.getCompanyStatisticsSet()) {
484
485 timeoutCount += getTimeoutCountByPortlet(
486 portletId, companyStatistics);
487 }
488
489 return timeoutCount;
490 }
491
492 public long getTimeoutCountByPortlet(String portletId, long companyId)
493 throws MonitoringException {
494
495 CompanyStatistics companyStatistics =
496 _serverStatistics.getCompanyStatistics(companyId);
497
498 return getTimeoutCountByPortlet(portletId, companyStatistics);
499 }
500
501 public long getTimeoutCountByPortlet(String portletId, String webId)
502 throws MonitoringException {
503
504 CompanyStatistics companyStatistics =
505 _serverStatistics.getCompanyStatistics(webId);
506
507 return getTimeoutCountByPortlet(portletId, companyStatistics);
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 }