Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ApplicationStatistics |
|
| 0.0;0 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.management.stats; | |
8 | ||
9 | /** | |
10 | * Aggregate statistics for all services and flows in an application. Do this by looping through all of the | |
11 | * applications' FlowConstructStatistics that aren;t themselves aggregators. | |
12 | */ | |
13 | public class ApplicationStatistics extends FlowConstructStatistics | |
14 | { | |
15 | private AllStatistics parent; | |
16 | ||
17 | public ApplicationStatistics(AllStatistics parent) | |
18 | { | |
19 | 0 | super("Application", "application totals", 0); |
20 | 0 | this.parent = parent; |
21 | 0 | } |
22 | ||
23 | @Override | |
24 | public long getAverageProcessingTime() | |
25 | { | |
26 | 0 | long totalTime = 0; |
27 | 0 | long totalEvents = 0; |
28 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
29 | { | |
30 | 0 | if (!(stats instanceof ApplicationStatistics)) |
31 | { | |
32 | 0 | totalEvents += stats.getProcessedEvents(); |
33 | 0 | totalTime += stats.getTotalProcessingTime(); |
34 | } | |
35 | } | |
36 | 0 | return totalEvents == 0 ? 0 : totalTime / totalEvents; |
37 | } | |
38 | ||
39 | @Override | |
40 | public long getProcessedEvents() | |
41 | { | |
42 | 0 | long total = 0; |
43 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
44 | { | |
45 | 0 | if (!(stats instanceof ApplicationStatistics)) |
46 | { | |
47 | 0 | total += stats.getProcessedEvents(); |
48 | } | |
49 | } | |
50 | 0 | return total; |
51 | } | |
52 | ||
53 | @Override | |
54 | public long getMinProcessingTime() | |
55 | { | |
56 | 0 | long min = 0; |
57 | 0 | boolean first = true; |
58 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
59 | { | |
60 | 0 | if (!(stats instanceof ApplicationStatistics)) |
61 | { | |
62 | 0 | long flowMin = stats.getMinProcessingTime(); |
63 | 0 | if (first) |
64 | { | |
65 | 0 | min = flowMin; |
66 | } | |
67 | else | |
68 | { | |
69 | 0 | min = Math.min(min, flowMin); |
70 | } | |
71 | } | |
72 | 0 | first = false; |
73 | } | |
74 | 0 | return min; |
75 | } | |
76 | ||
77 | @Override | |
78 | public long getMaxProcessingTime() | |
79 | { | |
80 | 0 | long max = 0; |
81 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
82 | { | |
83 | 0 | if (!(stats instanceof ApplicationStatistics)) |
84 | { | |
85 | 0 | max = Math.max(max, stats.getMaxProcessingTime()); |
86 | } | |
87 | } | |
88 | 0 | return max; |
89 | } | |
90 | ||
91 | @Override | |
92 | public long getTotalProcessingTime() | |
93 | { | |
94 | 0 | long total = 0; |
95 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
96 | { | |
97 | 0 | if (!(stats instanceof ApplicationStatistics)) |
98 | { | |
99 | 0 | total += stats.getTotalProcessingTime(); |
100 | } | |
101 | } | |
102 | 0 | return total; |
103 | } | |
104 | ||
105 | @Override | |
106 | public long getExecutionErrors() | |
107 | { | |
108 | 0 | long total = 0; |
109 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
110 | { | |
111 | 0 | if (!(stats instanceof ApplicationStatistics)) |
112 | { | |
113 | 0 | total += stats.getExecutionErrors(); |
114 | } | |
115 | } | |
116 | 0 | return total; |
117 | } | |
118 | ||
119 | @Override | |
120 | public long getFatalErrors() | |
121 | { | |
122 | 0 | long total = 0; |
123 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
124 | { | |
125 | 0 | if (!(stats instanceof ApplicationStatistics)) |
126 | { | |
127 | 0 | total += stats.getFatalErrors(); |
128 | } | |
129 | } | |
130 | 0 | return total; |
131 | } | |
132 | ||
133 | @Override | |
134 | public long getAsyncEventsReceived() | |
135 | { | |
136 | 0 | long total = 0; |
137 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
138 | { | |
139 | 0 | if (!(stats instanceof ApplicationStatistics)) |
140 | { | |
141 | 0 | total += stats.getAsyncEventsReceived(); |
142 | } | |
143 | } | |
144 | 0 | return total; |
145 | } | |
146 | ||
147 | @Override | |
148 | public long getSyncEventsReceived() | |
149 | { | |
150 | 0 | long total = 0; |
151 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
152 | { | |
153 | 0 | if (!(stats instanceof ApplicationStatistics)) |
154 | { | |
155 | 0 | total += stats.getSyncEventsReceived(); |
156 | } | |
157 | } | |
158 | 0 | return total; |
159 | } | |
160 | ||
161 | @Override | |
162 | public long getTotalEventsReceived() | |
163 | { | |
164 | 0 | long total = 0; |
165 | 0 | for (FlowConstructStatistics stats : parent.getServiceStatistics()) |
166 | { | |
167 | 0 | if (!(stats instanceof ApplicationStatistics)) |
168 | { | |
169 | 0 | total += stats.getTotalEventsReceived(); |
170 | } | |
171 | } | |
172 | 0 | return total; |
173 | } | |
174 | } |