001
014
015 package com.liferay.portal.monitoring.statistics.portlet;
016
017 import com.liferay.portal.kernel.monitoring.MonitoringException;
018 import com.liferay.portal.kernel.monitoring.statistics.RequestStatistics;
019
020 import java.util.Set;
021
022
026 public class ActionRequestSummaryStatistics
027 implements PortletSummaryStatistics {
028
029 @Override
030 public long getAverageTime() {
031 long averageTime = 0;
032
033 long count = 0;
034
035 for (CompanyStatistics companyStatistics :
036 _serverStatistics.getCompanyStatisticsSet()) {
037
038 for (RequestStatistics requestStatistics :
039 companyStatistics.getActionRequestStatisticsSet()) {
040
041 averageTime += requestStatistics.getAverageTime();
042
043 count++;
044 }
045 }
046
047 return averageTime / count;
048 }
049
050 @Override
051 public long getAverageTimeByCompany(long companyId)
052 throws MonitoringException {
053
054 CompanyStatistics companyStatistics =
055 _serverStatistics.getCompanyStatistics(companyId);
056
057 return getAverageTimeByCompany(companyStatistics);
058 }
059
060 @Override
061 public long getAverageTimeByCompany(String webId)
062 throws MonitoringException {
063
064 CompanyStatistics companyStatistics =
065 _serverStatistics.getCompanyStatistics(webId);
066
067 return getAverageTimeByCompany(companyStatistics);
068 }
069
070 @Override
071 public long getAverageTimeByPortlet(String portletId)
072 throws MonitoringException {
073
074 long averageTime = 0;
075
076 Set<CompanyStatistics> companyStatisticsSet =
077 _serverStatistics.getCompanyStatisticsSet();
078
079 for (CompanyStatistics companyStatistics : companyStatisticsSet) {
080 RequestStatistics requestStatistics =
081 companyStatistics.getActionRequestStatistics(portletId);
082
083 averageTime += requestStatistics.getAverageTime();
084 }
085
086 return averageTime / companyStatisticsSet.size();
087 }
088
089 @Override
090 public long getAverageTimeByPortlet(String portletId, long companyId)
091 throws MonitoringException {
092
093 CompanyStatistics companyStatistics =
094 _serverStatistics.getCompanyStatistics(companyId);
095
096 RequestStatistics requestStatistics =
097 companyStatistics.getActionRequestStatistics(portletId);
098
099 return requestStatistics.getAverageTime();
100 }
101
102 @Override
103 public long getAverageTimeByPortlet(String portletId, String webId)
104 throws MonitoringException {
105
106 CompanyStatistics companyStatistics =
107 _serverStatistics.getCompanyStatistics(webId);
108
109 RequestStatistics requestStatistics =
110 companyStatistics.getActionRequestStatistics(portletId);
111
112 return requestStatistics.getAverageTime();
113 }
114
115 @Override
116 public long getErrorCount() {
117 long errorCount = 0;
118
119 for (CompanyStatistics companyStatistics :
120 _serverStatistics.getCompanyStatisticsSet()) {
121
122 errorCount += getErrorCountByCompany(companyStatistics);
123 }
124
125 return errorCount;
126 }
127
128 @Override
129 public long getErrorCountByCompany(long companyId)
130 throws MonitoringException {
131
132 CompanyStatistics companyStatistics =
133 _serverStatistics.getCompanyStatistics(companyId);
134
135 return getErrorCountByCompany(companyStatistics);
136 }
137
138 @Override
139 public long getErrorCountByCompany(String webId)
140 throws MonitoringException {
141
142 CompanyStatistics companyStatistics =
143 _serverStatistics.getCompanyStatistics(webId);
144
145 return getErrorCountByCompany(companyStatistics);
146 }
147
148 @Override
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 @Override
164 public long getErrorCountByPortlet(String portletId, long companyId)
165 throws MonitoringException {
166
167 CompanyStatistics companyStatistics =
168 _serverStatistics.getCompanyStatistics(companyId);
169
170 return getErrorCountByPortlet(portletId, companyStatistics);
171 }
172
173 @Override
174 public long getErrorCountByPortlet(String portletId, String webId)
175 throws MonitoringException {
176
177 CompanyStatistics companyStatistics =
178 _serverStatistics.getCompanyStatistics(webId);
179
180 return getErrorCountByPortlet(portletId, companyStatistics);
181 }
182
183 @Override
184 public long getMaxTime() {
185 long maxTime = 0;
186
187 for (CompanyStatistics companyStatistics :
188 _serverStatistics.getCompanyStatisticsSet()) {
189
190 for (RequestStatistics requestStatistics :
191 companyStatistics.getActionRequestStatisticsSet()) {
192
193 if (requestStatistics.getMaxTime() > maxTime) {
194 maxTime = requestStatistics.getMaxTime();
195 }
196 }
197 }
198
199 return maxTime;
200 }
201
202 @Override
203 public long getMaxTimeByCompany(long companyId) throws MonitoringException {
204 CompanyStatistics companyStatistics =
205 _serverStatistics.getCompanyStatistics(companyId);
206
207 return companyStatistics.getMaxTime();
208 }
209
210 @Override
211 public long getMaxTimeByCompany(String webId) throws MonitoringException {
212 CompanyStatistics companyStatistics =
213 _serverStatistics.getCompanyStatistics(webId);
214
215 return companyStatistics.getMaxTime();
216 }
217
218 @Override
219 public long getMaxTimeByPortlet(String portletId)
220 throws MonitoringException {
221
222 long maxTime = 0;
223
224 for (CompanyStatistics companyStatistics :
225 _serverStatistics.getCompanyStatisticsSet()) {
226
227 long curMaxTime = getMaxTimeByPortlet(portletId, companyStatistics);
228
229 if (curMaxTime > maxTime) {
230 maxTime = curMaxTime;
231 }
232 }
233
234 return maxTime;
235 }
236
237 @Override
238 public long getMaxTimeByPortlet(String portletId, long companyId)
239 throws MonitoringException {
240
241 CompanyStatistics companyStatistics =
242 _serverStatistics.getCompanyStatistics(companyId);
243
244 return getMaxTimeByPortlet(portletId, companyStatistics);
245 }
246
247 @Override
248 public long getMaxTimeByPortlet(String portletId, String webId)
249 throws MonitoringException {
250
251 CompanyStatistics companyStatistics =
252 _serverStatistics.getCompanyStatistics(webId);
253
254 return getMaxTimeByPortlet(portletId, companyStatistics);
255 }
256
257 @Override
258 public long getMinTime() {
259 long minTime = 0;
260
261 for (CompanyStatistics companyStatistics :
262 _serverStatistics.getCompanyStatisticsSet()) {
263
264 for (RequestStatistics requestStatistics :
265 companyStatistics.getActionRequestStatisticsSet()) {
266
267 if (requestStatistics.getMinTime() < minTime) {
268 minTime = requestStatistics.getMinTime();
269 }
270 }
271 }
272
273 return minTime;
274 }
275
276 @Override
277 public long getMinTimeByCompany(long companyId) throws MonitoringException {
278 CompanyStatistics companyStatistics =
279 _serverStatistics.getCompanyStatistics(companyId);
280
281 return companyStatistics.getMinTime();
282 }
283
284 @Override
285 public long getMinTimeByCompany(String webId) throws MonitoringException {
286 CompanyStatistics companyStatistics =
287 _serverStatistics.getCompanyStatistics(webId);
288
289 return companyStatistics.getMinTime();
290 }
291
292 @Override
293 public long getMinTimeByPortlet(String portletId)
294 throws MonitoringException {
295
296 long minTime = 0;
297
298 for (CompanyStatistics companyStatistics :
299 _serverStatistics.getCompanyStatisticsSet()) {
300
301 long curMinTime = getMinTimeByPortlet(portletId, companyStatistics);
302
303 if (curMinTime < minTime) {
304 minTime = curMinTime;
305 }
306 }
307
308 return minTime;
309 }
310
311 @Override
312 public long getMinTimeByPortlet(String portletId, long companyId)
313 throws MonitoringException {
314
315 CompanyStatistics companyStatistics =
316 _serverStatistics.getCompanyStatistics(companyId);
317
318 return getMinTimeByPortlet(portletId, companyStatistics);
319 }
320
321 @Override
322 public long getMinTimeByPortlet(String portletId, String webId)
323 throws MonitoringException {
324
325 CompanyStatistics companyStatistics =
326 _serverStatistics.getCompanyStatistics(webId);
327
328 return getMinTimeByPortlet(portletId, companyStatistics);
329 }
330
331 @Override
332 public long getRequestCount() {
333 long requestCount = 0;
334
335 for (CompanyStatistics companyStatistics :
336 _serverStatistics.getCompanyStatisticsSet()) {
337
338 requestCount += getRequestCountByCompany(companyStatistics);
339 }
340
341 return requestCount;
342 }
343
344 @Override
345 public long getRequestCountByCompany(long companyId)
346 throws MonitoringException {
347
348 CompanyStatistics companyStatistics =
349 _serverStatistics.getCompanyStatistics(companyId);
350
351 return getRequestCountByCompany(companyStatistics);
352 }
353
354 @Override
355 public long getRequestCountByCompany(String webId)
356 throws MonitoringException {
357
358 CompanyStatistics companyStatistics =
359 _serverStatistics.getCompanyStatistics(webId);
360
361 return getRequestCountByCompany(companyStatistics);
362 }
363
364 @Override
365 public long getRequestCountByPortlet(String portletId)
366 throws MonitoringException {
367
368 long requestCount = 0;
369
370 for (CompanyStatistics companyStatistics :
371 _serverStatistics.getCompanyStatisticsSet()) {
372
373 requestCount += getRequestCountByPortlet(
374 portletId, companyStatistics);
375 }
376
377 return requestCount;
378 }
379
380 @Override
381 public long getRequestCountByPortlet(String portletId, long companyId)
382 throws MonitoringException {
383
384 CompanyStatistics companyStatistics =
385 _serverStatistics.getCompanyStatistics(companyId);
386
387 return getRequestCountByPortlet(portletId, companyStatistics);
388 }
389
390 @Override
391 public long getRequestCountByPortlet(String portletId, String webId)
392 throws MonitoringException {
393
394 CompanyStatistics companyStatistics =
395 _serverStatistics.getCompanyStatistics(webId);
396
397 return getRequestCountByPortlet(portletId, companyStatistics);
398 }
399
400 @Override
401 public long getSuccessCount() {
402 long successCount = 0;
403
404 for (CompanyStatistics companyStatistics :
405 _serverStatistics.getCompanyStatisticsSet()) {
406
407 successCount += getSuccessCountByCompany(companyStatistics);
408 }
409
410 return successCount;
411 }
412
413 @Override
414 public long getSuccessCountByCompany(long companyId)
415 throws MonitoringException {
416
417 CompanyStatistics companyStatistics =
418 _serverStatistics.getCompanyStatistics(companyId);
419
420 return getSuccessCountByCompany(companyStatistics);
421 }
422
423 @Override
424 public long getSuccessCountByCompany(String webId)
425 throws MonitoringException {
426
427 CompanyStatistics companyStatistics =
428 _serverStatistics.getCompanyStatistics(webId);
429
430 return getSuccessCountByCompany(companyStatistics);
431 }
432
433 @Override
434 public long getSuccessCountByPortlet(String portletId)
435 throws MonitoringException {
436
437 long successCount = 0;
438
439 for (CompanyStatistics companyStatistics :
440 _serverStatistics.getCompanyStatisticsSet()) {
441
442 successCount += getSuccessCountByPortlet(
443 portletId, companyStatistics);
444 }
445
446 return successCount;
447 }
448
449 @Override
450 public long getSuccessCountByPortlet(String portletId, long companyId)
451 throws MonitoringException {
452
453 CompanyStatistics companyStatistics =
454 _serverStatistics.getCompanyStatistics(companyId);
455
456 return getSuccessCountByPortlet(portletId, companyStatistics);
457 }
458
459 @Override
460 public long getSuccessCountByPortlet(String portletId, String webId)
461 throws MonitoringException {
462
463 CompanyStatistics companyStatistics =
464 _serverStatistics.getCompanyStatistics(webId);
465
466 return getSuccessCountByPortlet(portletId, companyStatistics);
467 }
468
469 @Override
470 public long getTimeoutCount() {
471 long timeoutCount = 0;
472
473 for (CompanyStatistics companyStatistics :
474 _serverStatistics.getCompanyStatisticsSet()) {
475
476 timeoutCount += getTimeoutCountByCompany(companyStatistics);
477 }
478
479 return timeoutCount;
480 }
481
482 @Override
483 public long getTimeoutCountByCompany(long companyId)
484 throws MonitoringException {
485
486 CompanyStatistics companyStatistics =
487 _serverStatistics.getCompanyStatistics(companyId);
488
489 return getTimeoutCountByCompany(companyStatistics);
490 }
491
492 @Override
493 public long getTimeoutCountByCompany(String webId)
494 throws MonitoringException {
495
496 CompanyStatistics companyStatistics =
497 _serverStatistics.getCompanyStatistics(webId);
498
499 return getTimeoutCountByCompany(companyStatistics);
500 }
501
502 @Override
503 public long getTimeoutCountByPortlet(String portletId)
504 throws MonitoringException {
505
506 long timeoutCount = 0;
507
508 for (CompanyStatistics companyStatistics :
509 _serverStatistics.getCompanyStatisticsSet()) {
510
511 timeoutCount += getTimeoutCountByPortlet(
512 portletId, companyStatistics);
513 }
514
515 return timeoutCount;
516 }
517
518 @Override
519 public long getTimeoutCountByPortlet(String portletId, long companyId)
520 throws MonitoringException {
521
522 CompanyStatistics companyStatistics =
523 _serverStatistics.getCompanyStatistics(companyId);
524
525 return getTimeoutCountByPortlet(portletId, companyStatistics);
526 }
527
528 @Override
529 public long getTimeoutCountByPortlet(String portletId, String webId)
530 throws MonitoringException {
531
532 CompanyStatistics companyStatistics =
533 _serverStatistics.getCompanyStatistics(webId);
534
535 return getTimeoutCountByPortlet(portletId, companyStatistics);
536 }
537
538 public void setServerStatistics(ServerStatistics serverStatistics) {
539 _serverStatistics = serverStatistics;
540 }
541
542 protected long getAverageTimeByCompany(
543 CompanyStatistics companyStatistics) {
544
545 long averageTime = 0;
546
547 Set<RequestStatistics> requestStatisticsSet =
548 companyStatistics.getActionRequestStatisticsSet();
549
550 for (RequestStatistics requestStatistics : requestStatisticsSet) {
551 averageTime += requestStatistics.getAverageTime();
552 }
553
554 return averageTime / requestStatisticsSet.size();
555 }
556
557 protected long getErrorCountByCompany(CompanyStatistics companyStatistics) {
558 long errorCount = 0;
559
560 for (RequestStatistics requestStatistics :
561 companyStatistics.getActionRequestStatisticsSet()) {
562
563 errorCount += requestStatistics.getErrorCount();
564 }
565
566 return errorCount;
567 }
568
569 protected long getErrorCountByPortlet(
570 String portletId, CompanyStatistics companyStatistics)
571 throws MonitoringException {
572
573 RequestStatistics requestStatistics =
574 companyStatistics.getActionRequestStatistics(portletId);
575
576 return requestStatistics.getErrorCount();
577 }
578
579 protected long getMaxTimeByPortlet(
580 String portletId, CompanyStatistics companyStatistics)
581 throws MonitoringException {
582
583 long maxTime = 0;
584
585 RequestStatistics requestStatistics =
586 companyStatistics.getActionRequestStatistics(portletId);
587
588 if (requestStatistics.getMaxTime() > maxTime) {
589 maxTime = requestStatistics.getMaxTime();
590 }
591
592 return maxTime;
593 }
594
595 protected long getMinTimeByPortlet(
596 String portletId, CompanyStatistics companyStatistics)
597 throws MonitoringException {
598
599 long minTime = 0;
600
601 RequestStatistics requestStatistics =
602 companyStatistics.getActionRequestStatistics(portletId);
603
604 if (requestStatistics.getMinTime() < minTime) {
605 minTime = requestStatistics.getMinTime();
606 }
607
608 return minTime;
609 }
610
611 protected long getRequestCountByCompany(
612 CompanyStatistics companyStatistics) {
613
614 long requestCount = 0;
615
616 for (RequestStatistics requestStatistics :
617 companyStatistics.getActionRequestStatisticsSet()) {
618
619 requestCount += requestStatistics.getRequestCount();
620 }
621
622 return requestCount;
623 }
624
625 protected long getRequestCountByPortlet(
626 String portletId, CompanyStatistics companyStatistics)
627 throws MonitoringException {
628
629 RequestStatistics requestStatistics =
630 companyStatistics.getActionRequestStatistics(portletId);
631
632 return requestStatistics.getRequestCount();
633 }
634
635 protected long getSuccessCountByCompany(
636 CompanyStatistics companyStatistics) {
637
638 long successCount = 0;
639
640 for (RequestStatistics requestStatistics :
641 companyStatistics.getActionRequestStatisticsSet()) {
642
643 successCount += requestStatistics.getSuccessCount();
644 }
645
646 return successCount;
647 }
648
649 protected long getSuccessCountByPortlet(
650 String portletId, CompanyStatistics companyStatistics)
651 throws MonitoringException {
652
653 RequestStatistics requestStatistics =
654 companyStatistics.getActionRequestStatistics(portletId);
655
656 return requestStatistics.getSuccessCount();
657 }
658
659 protected long getTimeoutCountByCompany(
660 CompanyStatistics companyStatistics) {
661
662 long timeoutCount = 0;
663
664 for (RequestStatistics requestStatistics :
665 companyStatistics.getActionRequestStatisticsSet()) {
666
667 timeoutCount += requestStatistics.getTimeoutCount();
668 }
669
670 return timeoutCount;
671 }
672
673 protected long getTimeoutCountByPortlet(
674 String portletId, CompanyStatistics companyStatistics)
675 throws MonitoringException {
676
677 RequestStatistics requestStatistics =
678 companyStatistics.getActionRequestStatistics(portletId);
679
680 return requestStatistics.getTimeoutCount();
681 }
682
683 private ServerStatistics _serverStatistics;
684
685 }