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