1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.management.mbeans; |
12 | |
|
13 | |
import org.mule.management.stats.ComponentStatistics; |
14 | |
import org.mule.management.stats.RouterStatistics; |
15 | |
|
16 | |
import javax.management.MBeanRegistration; |
17 | |
import javax.management.MBeanServer; |
18 | |
import javax.management.ObjectName; |
19 | |
|
20 | |
import org.apache.commons.logging.Log; |
21 | |
import org.apache.commons.logging.LogFactory; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class ComponentStats implements ComponentStatsMBean, MBeanRegistration |
27 | |
{ |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | 4 | private static Log LOGGER = LogFactory.getLog(ComponentStats.class); |
33 | |
|
34 | |
private MBeanServer server; |
35 | |
|
36 | |
private ObjectName name; |
37 | |
private ObjectName inboundName; |
38 | |
private ObjectName outboundName; |
39 | |
|
40 | |
private ComponentStatistics statistics; |
41 | |
|
42 | |
public ComponentStats(ComponentStatistics statistics) |
43 | 4 | { |
44 | 4 | this.statistics = statistics; |
45 | 4 | } |
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
public void clearStatistics() |
51 | |
{ |
52 | 0 | statistics.clear(); |
53 | 0 | } |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
public long getAsyncEventsReceived() |
59 | |
{ |
60 | 0 | return statistics.getAsyncEventsReceived(); |
61 | |
} |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public long getAsyncEventsSent() |
67 | |
{ |
68 | 0 | return statistics.getAsyncEventsSent(); |
69 | |
} |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
public long getAverageExecutionTime() |
75 | |
{ |
76 | 0 | return statistics.getAverageExecutionTime(); |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
public long getAverageQueueSize() |
83 | |
{ |
84 | 0 | return statistics.getAverageQueueSize(); |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
public long getExecutedEvents() |
91 | |
{ |
92 | 0 | return statistics.getExecutedEvents(); |
93 | |
} |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public long getExecutionErrors() |
99 | |
{ |
100 | 0 | return statistics.getExecutionErrors(); |
101 | |
} |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
public long getFatalErrors() |
107 | |
{ |
108 | 0 | return statistics.getFatalErrors(); |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public long getMaxExecutionTime() |
115 | |
{ |
116 | 0 | return statistics.getMaxExecutionTime(); |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public long getMaxQueueSize() |
123 | |
{ |
124 | 0 | return statistics.getMaxQueueSize(); |
125 | |
} |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public long getMinExecutionTime() |
131 | |
{ |
132 | 0 | return statistics.getMinExecutionTime(); |
133 | |
} |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public String getName() |
139 | |
{ |
140 | 0 | return statistics.getName(); |
141 | |
} |
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
public long getQueuedEvents() |
147 | |
{ |
148 | 0 | return statistics.getQueuedEvents(); |
149 | |
} |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
public long getReplyToEventsSent() |
155 | |
{ |
156 | 0 | return statistics.getReplyToEventsSent(); |
157 | |
} |
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public long getSyncEventsReceived() |
163 | |
{ |
164 | 0 | return statistics.getSyncEventsReceived(); |
165 | |
} |
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
public long getSyncEventsSent() |
171 | |
{ |
172 | 0 | return statistics.getSyncEventsSent(); |
173 | |
} |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
public long getTotalEventsReceived() |
179 | |
{ |
180 | 0 | return statistics.getTotalEventsReceived(); |
181 | |
} |
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
public long getTotalEventsSent() |
187 | |
{ |
188 | 0 | return statistics.getTotalEventsSent(); |
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
public long getTotalExecutionTime() |
195 | |
{ |
196 | 0 | return statistics.getTotalExecutionTime(); |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception |
206 | |
{ |
207 | 4 | this.server = server; |
208 | 4 | this.name = name; |
209 | 4 | return name; |
210 | |
} |
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
public void postRegister(Boolean registrationDone) |
218 | |
{ |
219 | |
|
220 | |
try |
221 | |
{ |
222 | 4 | RouterStatistics is = this.statistics.getInboundRouterStat(); |
223 | 4 | if (is != null) |
224 | |
{ |
225 | 4 | inboundName = new ObjectName(name.getDomain() + ":type=org.mule.Statistics,component=" |
226 | |
+ statistics.getName() + ",router=inbound"); |
227 | |
|
228 | 4 | if (this.server.isRegistered(inboundName)) |
229 | |
{ |
230 | 0 | this.server.unregisterMBean(inboundName); |
231 | |
} |
232 | 4 | this.server.registerMBean(new RouterStats(is), this.inboundName); |
233 | |
} |
234 | 4 | RouterStatistics os = this.statistics.getOutboundRouterStat(); |
235 | 4 | if (os != null) |
236 | |
{ |
237 | 4 | outboundName = new ObjectName(name.getDomain() + ":type=org.mule.Statistics,component=" |
238 | |
+ statistics.getName() + ",router=outbound"); |
239 | |
|
240 | 4 | if (this.server.isRegistered(outboundName)) |
241 | |
{ |
242 | 0 | this.server.unregisterMBean(outboundName); |
243 | |
} |
244 | 4 | this.server.registerMBean(new RouterStats(os), this.outboundName); |
245 | |
} |
246 | |
} |
247 | 0 | catch (Exception e) |
248 | |
{ |
249 | 0 | LOGGER.error("Error post-registering MBean", e); |
250 | 4 | } |
251 | |
|
252 | 4 | } |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
public void preDeregister() throws Exception |
260 | |
{ |
261 | |
|
262 | 4 | } |
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
public void postDeregister() |
270 | |
{ |
271 | |
try |
272 | |
{ |
273 | 4 | if (this.server.isRegistered(inboundName)) |
274 | |
{ |
275 | 4 | this.server.unregisterMBean(inboundName); |
276 | |
} |
277 | |
} |
278 | 0 | catch (Exception ex) |
279 | |
{ |
280 | 0 | LOGGER.error("Error unregistering ComponentStats child " + inboundName.getCanonicalName(), ex); |
281 | 4 | } |
282 | |
try |
283 | |
{ |
284 | 4 | if (this.server.isRegistered(outboundName)) |
285 | |
{ |
286 | 4 | this.server.unregisterMBean(outboundName); |
287 | |
} |
288 | |
} |
289 | 0 | catch (Exception ex) |
290 | |
{ |
291 | 0 | LOGGER.error("Error unregistering ComponentStats child " + inboundName.getCanonicalName(), ex); |
292 | 4 | } |
293 | 4 | } |
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
public ObjectName getRouterInbound() |
301 | |
{ |
302 | 0 | return this.inboundName; |
303 | |
} |
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
public ObjectName getRouterOutbound() |
311 | |
{ |
312 | 0 | return this.outboundName; |
313 | |
} |
314 | |
} |