Search in sources :

Example 6 with GangliaSink30

use of org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30 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)6 DatagramSocket (java.net.DatagramSocket)4 MulticastSocket (java.net.MulticastSocket)4 SubsetConfiguration (org.apache.commons.configuration2.SubsetConfiguration)4 ConfigBuilder (org.apache.hadoop.metrics2.impl.ConfigBuilder)4 GangliaSink30 (org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AbstractMetric (org.apache.hadoop.metrics2.AbstractMetric)1 MetricsRecord (org.apache.hadoop.metrics2.MetricsRecord)1 MetricsTag (org.apache.hadoop.metrics2.MetricsTag)1 AbstractGangliaSink (org.apache.hadoop.metrics2.sink.ganglia.AbstractGangliaSink)1 GangliaSink31 (org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31)1