|
20 | 20 | import javax.rmi.ssl.SslRMIClientSocketFactory; |
21 | 21 | import java.io.IOException; |
22 | 22 | import java.lang.management.ManagementFactory; |
23 | | -import java.util.HashMap; |
24 | | -import java.util.HashSet; |
25 | | -import java.util.LinkedHashMap; |
26 | | -import java.util.LinkedList; |
27 | | -import java.util.List; |
28 | | -import java.util.Map; |
29 | | -import java.util.Set; |
30 | | -import java.util.TreeSet; |
| 23 | +import java.util.*; |
31 | 24 | import java.util.logging.Level; |
32 | 25 | import java.util.logging.Logger; |
33 | 26 |
|
@@ -157,28 +150,22 @@ private void scrapeBean(MBeanServerConnection beanConn, ObjectName mbeanName) { |
157 | 150 | logScrape(mbeanName, name2AttrInfo.keySet(), "Fail: " + e); |
158 | 151 | return; |
159 | 152 | } |
160 | | - try { |
161 | | - for (Object attributeObj : attributes.asList()) { |
162 | | - if (Attribute.class.isInstance(attributeObj)) { |
163 | | - Attribute attribute = (Attribute)(attributeObj); |
164 | | - MBeanAttributeInfo attr = name2AttrInfo.get(attribute.getName()); |
165 | | - logScrape(mbeanName, attr, "process"); |
166 | | - processBeanValue( |
167 | | - mbeanName.getDomain(), |
168 | | - jmxMBeanPropertyCache.getKeyPropertyList(mbeanName), |
169 | | - new LinkedList<String>(), |
170 | | - attr.getName(), |
171 | | - attr.getType(), |
172 | | - attr.getDescription(), |
173 | | - attribute.getValue() |
174 | | - ); |
175 | | - } |
| 153 | + for (Object attributeObj : attributes) { |
| 154 | + if (Attribute.class.isInstance(attributeObj)) { |
| 155 | + Attribute attribute = (Attribute)(attributeObj); |
| 156 | + MBeanAttributeInfo attr = name2AttrInfo.get(attribute.getName()); |
| 157 | + logScrape(mbeanName, attr, "process"); |
| 158 | + processBeanValue( |
| 159 | + mbeanName.getDomain(), |
| 160 | + jmxMBeanPropertyCache.getKeyPropertyList(mbeanName), |
| 161 | + new LinkedList<String>(), |
| 162 | + attr.getName(), |
| 163 | + attr.getType(), |
| 164 | + attr.getDescription(), |
| 165 | + attribute.getValue() |
| 166 | + ); |
176 | 167 | } |
177 | 168 | } |
178 | | - catch (Exception e) { |
179 | | - logScrape(mbeanName.toString(), "failed to process attribute"); |
180 | | - return; |
181 | | - } |
182 | 169 | } |
183 | 170 |
|
184 | 171 |
|
@@ -288,6 +275,18 @@ private void processBeanValue( |
288 | 275 | } |
289 | 276 | } else if (value.getClass().isArray()) { |
290 | 277 | logScrape(domain, "arrays are unsupported"); |
| 278 | + } else if (value instanceof ArrayList<?>) { |
| 279 | + // We can't output a list of values here, so instead let's send the count of entries |
| 280 | + ArrayList<?> list = (ArrayList<?>)value; |
| 281 | + logScrape(domain + beanProperties + attrName, String.valueOf(list.size())); |
| 282 | + this.receiver.recordBean( |
| 283 | + domain, |
| 284 | + beanProperties, |
| 285 | + attrKeys, |
| 286 | + attrName, |
| 287 | + attrType, |
| 288 | + attrDescription, |
| 289 | + list.size()); |
291 | 290 | } else { |
292 | 291 | logScrape(domain + beanProperties, attrType + " is not exported"); |
293 | 292 | } |
|
0 commit comments