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