Skip to content

Commit

Permalink
[attribute][complex] extend to java.util.Map (#130)
Browse files Browse the repository at this point in the history
Add `java.util.Map` to the list of supported `JMXComplexAttribute`
types.
  • Loading branch information
yannmh authored Mar 2, 2017
1 parent 4d14750 commit dfc5698
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/datadog/jmxfetch/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Instance {
"java.lang.String", "int", "float", "double", "java.lang.Double","java.lang.Float", "java.lang.Integer", "java.lang.Long",
"java.util.concurrent.atomic.AtomicInteger", "java.util.concurrent.atomic.AtomicLong",
"java.lang.Object", "java.lang.Boolean", "boolean", "java.lang.Number");
private final static List<String> COMPOSED_TYPES = Arrays.asList("javax.management.openmbean.CompositeData", "java.util.HashMap");
private final static List<String> COMPOSED_TYPES = Arrays.asList("javax.management.openmbean.CompositeData", "java.util.HashMap", "java.util.Map");
private final static int MAX_RETURNED_METRICS = 350;
private final static int DEFAULT_REFRESH_BEANS_PERIOD = 600;
public static final String PROCESS_NAME_REGEX = "process_name_regex";
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/datadog/jmxfetch/JMXComplexAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ private void populateSubAttributeList(Object attributeValue) {
for (String key : data.getCompositeType().keySet()) {
this.subAttributeList.put(key, new HashMap<String, Object>());
}
} else if ("java.util.HashMap".equals(attributeType)) {
HashMap<String, Double> data = (HashMap<String, Double>) attributeValue;
} else if (("java.util.HashMap".equals(attributeType)) || ("java.util.Map".equals(attributeType))){
Map<String, Double> data = (Map<String, Double>) attributeValue;
for (String key : data.keySet()) {
this.subAttributeList.put(key, new HashMap<String, Object>());
}
Expand Down Expand Up @@ -83,8 +83,8 @@ private double getValue(String subAttribute) throws AttributeNotFoundException,
CompositeData data = (CompositeData) value;
return getValueAsDouble(data.get(subAttribute));

} else if ("java.util.HashMap".equals(attributeType)) {
HashMap<String, Object> data = (HashMap<String, Object>) value;
} else if (("java.util.HashMap".equals(attributeType)) || ("java.util.Map".equals(attributeType))) {
Map<String, Object> data = (Map<String, Object>) value;
return getValueAsDouble(data.get(subAttribute));
}
throw new NumberFormatException();
Expand Down

0 comments on commit dfc5698

Please sign in to comment.