use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestPatternFilter method includeShouldOverrideExclude.
/**
* Include patterns should take precedence over exclude patterns
*/
@Test
public void includeShouldOverrideExclude() {
SubsetConfiguration c = new ConfigBuilder().add("p.include", "foo").add("p.include.tags", "foo:f").add("p.exclude", "foo").add("p.exclude.tags", "foo:f").subset("p");
shouldAccept(c, "foo");
shouldAccept(c, Arrays.asList(tag("foo", "", "f")));
shouldAccept(c, mockMetricsRecord("foo", Arrays.asList(tag("foo", "", "f"))));
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestPatternFilter method shouldAcceptUnmatchedWhenBothAreConfigured.
/**
* Filters should accepts unmatched item when both include and
* exclude patterns are present.
*/
@Test
public void shouldAcceptUnmatchedWhenBothAreConfigured() {
SubsetConfiguration c = new ConfigBuilder().add("p.include", "foo").add("p.include.tags", "foo:f").add("p.exclude", "bar").add("p.exclude.tags", "bar:b").subset("p");
shouldAccept(c, "foo");
shouldAccept(c, Arrays.asList(tag("foo", "", "f")));
shouldAccept(c, mockMetricsRecord("foo", Arrays.asList(tag("foo", "", "f"))));
shouldReject(c, "bar");
shouldReject(c, Arrays.asList(tag("bar", "", "b")));
shouldReject(c, mockMetricsRecord("bar", Arrays.asList(tag("foo", "", "f"))));
shouldReject(c, mockMetricsRecord("foo", Arrays.asList(tag("bar", "", "b"))));
shouldAccept(c, "foobar");
shouldAccept(c, Arrays.asList(tag("foobar", "", "")));
shouldAccept(c, mockMetricsRecord("foobar", Arrays.asList(tag("foobar", "", ""))));
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestPatternFilter method includeOnlyShouldOnlyIncludeMatched.
/**
* Filters should handle white-listing correctly
*/
@Test
public void includeOnlyShouldOnlyIncludeMatched() {
SubsetConfiguration wl = new ConfigBuilder().add("p.include", "foo").add("p.include.tags", "foo:f").subset("p");
shouldAccept(wl, "foo");
shouldAccept(wl, Arrays.asList(tag("bar", "", ""), tag("foo", "", "f")), new boolean[] { false, true });
shouldAccept(wl, mockMetricsRecord("foo", Arrays.asList(tag("bar", "", ""), tag("foo", "", "f"))));
shouldReject(wl, "bar");
shouldReject(wl, Arrays.asList(tag("bar", "", "")));
shouldReject(wl, Arrays.asList(tag("foo", "", "boo")));
shouldReject(wl, mockMetricsRecord("bar", Arrays.asList(tag("foo", "", "f"))));
shouldReject(wl, mockMetricsRecord("foo", Arrays.asList(tag("bar", "", ""))));
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestMetricsCollectorImpl method recordBuilderShouldNoOpIfFiltered.
@Test
public void recordBuilderShouldNoOpIfFiltered() {
SubsetConfiguration fc = new ConfigBuilder().add("p.exclude", "foo").subset("p");
MetricsCollectorImpl mb = new MetricsCollectorImpl();
mb.setRecordFilter(newGlobFilter(fc));
MetricsRecordBuilderImpl rb = mb.addRecord("foo");
rb.tag(info("foo", ""), "value").addGauge(info("g0", ""), 1);
assertEquals("no tags", 0, rb.tags().size());
assertEquals("no metrics", 0, rb.metrics().size());
assertNull("null record", rb.getRecord());
assertEquals("no records", 0, mb.getRecords().size());
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestMetricsCollectorImpl method testPerMetricFiltering.
@Test
public void testPerMetricFiltering() {
SubsetConfiguration fc = new ConfigBuilder().add("p.exclude", "foo").subset("p");
MetricsCollectorImpl mb = new MetricsCollectorImpl();
mb.setMetricFilter(newGlobFilter(fc));
MetricsRecordBuilderImpl rb = mb.addRecord("foo");
rb.tag(info("foo", ""), "").addCounter(info("c0", ""), 0).addGauge(info("foo", ""), 1);
assertEquals("1 tag", 1, rb.tags().size());
assertEquals("1 metric", 1, rb.metrics().size());
assertEquals("expect foo tag", "foo", rb.tags().get(0).name());
assertEquals("expect c0", "c0", rb.metrics().get(0).name());
}
Aggregations