Search in sources :

Example 21 with ConfigBuilder

use of org.apache.hadoop.metrics2.impl.ConfigBuilder 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);
}
Also used : MulticastSocket(java.net.MulticastSocket) DatagramSocket(java.net.DatagramSocket) ConfigBuilder(org.apache.hadoop.metrics2.impl.ConfigBuilder) SubsetConfiguration(org.apache.commons.configuration2.SubsetConfiguration) Test(org.junit.Test)

Example 22 with ConfigBuilder

use of org.apache.hadoop.metrics2.impl.ConfigBuilder 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);
}
Also used : MulticastSocket(java.net.MulticastSocket) DatagramSocket(java.net.DatagramSocket) ConfigBuilder(org.apache.hadoop.metrics2.impl.ConfigBuilder) SubsetConfiguration(org.apache.commons.configuration2.SubsetConfiguration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 ConfigBuilder (org.apache.hadoop.metrics2.impl.ConfigBuilder)16 SubsetConfiguration (org.apache.commons.configuration2.SubsetConfiguration)11 DatagramSocket (java.net.DatagramSocket)4 MulticastSocket (java.net.MulticastSocket)4 MetricsRecord (org.apache.hadoop.metrics2.MetricsRecord)4 MetricsSink (org.apache.hadoop.metrics2.MetricsSink)4 Configuration (org.apache.hadoop.conf.Configuration)2 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)2 AbstractMetric (org.apache.hadoop.metrics2.AbstractMetric)2 MetricsSystemImpl (org.apache.hadoop.metrics2.impl.MetricsSystemImpl)2 GangliaSink30 (org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30)2 Predicate (com.google.common.base.Predicate)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Pattern (java.util.regex.Pattern)1 Nullable (javax.annotation.Nullable)1