use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestPatternFilter method excludeOnlyShouldOnlyExcludeMatched.
/**
* Filters should handle black-listing correctly
*/
@Test
public void excludeOnlyShouldOnlyExcludeMatched() {
SubsetConfiguration bl = new ConfigBuilder().add("p.exclude", "foo").add("p.exclude.tags", "foo:f").subset("p");
shouldAccept(bl, "bar");
shouldAccept(bl, Arrays.asList(tag("bar", "", "")));
shouldAccept(bl, mockMetricsRecord("bar", Arrays.asList(tag("bar", "", ""))));
shouldReject(bl, "foo");
shouldReject(bl, Arrays.asList(tag("bar", "", ""), tag("foo", "", "f")), new boolean[] { true, false });
shouldReject(bl, mockMetricsRecord("foo", Arrays.asList(tag("bar", "", ""))));
shouldReject(bl, mockMetricsRecord("bar", Arrays.asList(tag("bar", "", ""), tag("foo", "", "f"))));
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestPatternFilter method emptyConfigShouldAccept.
/**
* Filters should default to accept
*/
@Test
public void emptyConfigShouldAccept() {
SubsetConfiguration empty = new ConfigBuilder().subset("");
shouldAccept(empty, "anything");
shouldAccept(empty, Arrays.asList(tag("key", "desc", "value")));
shouldAccept(empty, mockMetricsRecord("anything", Arrays.asList(tag("key", "desc", "value"))));
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class GangliaSink30 method init.
@Override
@SuppressWarnings("unchecked")
public void init(SubsetConfiguration conf) {
super.init(conf);
conf.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
Iterator<String> it = (Iterator<String>) conf.getKeys();
while (it.hasNext()) {
String propertyName = it.next();
if (propertyName.startsWith(TAGS_FOR_PREFIX_PROPERTY_PREFIX)) {
String contextName = propertyName.substring(TAGS_FOR_PREFIX_PROPERTY_PREFIX.length());
String[] tags = conf.getStringArray(propertyName);
boolean useAllTags = false;
Set<String> set = new HashSet<>();
for (String tag : tags) {
tag = tag.trim();
useAllTags |= tag.equals("*");
if (tag.length() > 0) {
set.add(tag);
}
}
if (useAllTags) {
set = null;
}
useTagsMap.put(contextName, set);
}
}
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestGangliaSink method testShouldCreateMulticastSocket.
@Test
public void testShouldCreateMulticastSocket() throws Exception {
SubsetConfiguration conf = new ConfigBuilder().add("test.sink.ganglia.multicast", true).subset("test.sink.ganglia");
GangliaSink30 gangliaSink = new GangliaSink30();
gangliaSink.init(conf);
DatagramSocket socket = gangliaSink.getDatagramSocket();
assertTrue("Did not create MulticastSocket", socket != null && socket instanceof MulticastSocket);
int ttl = ((MulticastSocket) socket).getTimeToLive();
assertEquals("Did not set default TTL", 1, ttl);
}
use of org.apache.commons.configuration2.SubsetConfiguration in project hadoop by apache.
the class TestGangliaSink method testShouldSetMulticastSocketTtl.
@Test
public void testShouldSetMulticastSocketTtl() throws Exception {
SubsetConfiguration conf = new ConfigBuilder().add("test.sink.ganglia.multicast", true).add("test.sink.ganglia.multicast.ttl", 3).subset("test.sink.ganglia");
GangliaSink30 gangliaSink = new GangliaSink30();
gangliaSink.init(conf);
DatagramSocket socket = gangliaSink.getDatagramSocket();
assertTrue("Did not create MulticastSocket", socket != null && socket instanceof MulticastSocket);
int ttl = ((MulticastSocket) socket).getTimeToLive();
assertEquals("Did not set TTL", 3, ttl);
}
Aggregations