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