Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bean name matching logic: OR→AND #77

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -21,7 +21,7 @@
public class Instance {
private final static Logger LOGGER = Logger.getLogger(Instance.class.getName());
private final static List<String> SIMPLE_TYPES = Arrays.asList("long",
"java.lang.String", "int", "double", "java.lang.Double", "java.lang.Integer", "java.lang.Long",
"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");
Expand Down
20 changes: 3 additions & 17 deletions src/main/java/org/datadog/jmxfetch/JMXAttribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,10 @@ private boolean matchBeanRegex(Filter filter, boolean matchIfNoRegex) {
return true;
}
}

return false;
}

private boolean matchBeanName(Configuration configuration) {
boolean matchBeanAttr = true;
Filter include = configuration.getInclude();

if (!include.isEmptyBeanName() && !include.getBeanNames().contains(beanStringName)) {
Expand All @@ -233,26 +231,14 @@ private boolean matchBeanName(Configuration configuration) {
if (EXCLUDED_BEAN_PARAMS.contains(bean_attr)) {
continue;
}
matchBeanAttr = false;

if (beanParameters.get(bean_attr) == null) {
continue;
}

ArrayList<String> beanValues = include.getParameterValues(bean_attr);


for (String beanVal : beanValues) {
if (!beanParameters.get(bean_attr).equals(beanVal)) {
continue;
if (beanParameters.get(bean_attr) == null || !(beanValues.contains(beanParameters.get(bean_attr)))){
return false;
}
return true;
}
// We havent' found a match among our attribute values list
return false;
}
// Returns true if all bean_attr belong to EXCLUDED_BEAN_PARAMS otherwise false
return matchBeanAttr;
return true;
}

private boolean excludeMatchBeanName(Configuration conf) {
Expand Down
25 changes: 0 additions & 25 deletions src/test/java/org/datadog/jmxfetch/CommonTestSetup.java

This file was deleted.

25 changes: 21 additions & 4 deletions src/test/java/org/datadog/jmxfetch/SimpleTestJavaApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@

public class SimpleTestJavaApp implements SimpleTestJavaAppMBean {

// Integers
private final int shouldBe100 = 100;
private final int shouldBe1000 = 1000;
private final Integer int424242 = new Integer(424242);
private final AtomicInteger atomic42 = new AtomicInteger(42);

private int shouldBeCounter = 0;

// Floats & Long
private final float primitiveFloat = 123.4f;
private final Float instanceFloat = 567.8f;
private final AtomicLong atomic4242 = new AtomicLong(4242);
private final Long long42424242 = new Long(42424242);

// String
private final String shouldBeConverted = "ShouldBe5";
private final String shouldBeDefaulted = "DefaultMe";

// Others
private final boolean shouldBeBoolean = true;
private final HashMap<String, Integer> hashmap = new HashMap<String, Integer>();
private final AtomicInteger atomic42 = new AtomicInteger(42);
private final AtomicLong atomic4242 = new AtomicLong(4242);
private final Object object1337 = new Double(13.37);
private final Long long42424242 = new Long(42424242);
private final Integer int424242 = new Integer(424242);
private final BigDecimal numberBig = new BigDecimal(123456788901234567890.0);


SimpleTestJavaApp() {
hashmap.put("thisis0", 0);
hashmap.put("thisis10", 10);
Expand Down Expand Up @@ -93,5 +104,11 @@ public Integer getInt424242() {
return int424242;
}

public float getPrimitiveFloat(){
return primitiveFloat;
}

public Float getInstanceFloat(){
return instanceFloat;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public interface SimpleTestJavaAppMBean {

Integer getInt424242();

float getPrimitiveFloat();

Float getInstanceFloat();

}
Loading