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