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