本文整理汇总了Java中org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricsTestHelper类的典型用法代码示例。如果您正苦于以下问题:Java GangliaMetricsTestHelper类的具体用法?Java GangliaMetricsTestHelper怎么用?Java GangliaMetricsTestHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GangliaMetricsTestHelper类属于org.apache.hadoop.metrics2.sink.ganglia包,在下文中一共展示了GangliaMetricsTestHelper类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGangliaMetrics2
import org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricsTestHelper; //导入依赖的package包/类
@Test public void testGangliaMetrics2() throws Exception {
ConfigBuilder cb = new ConfigBuilder().add("default.period", 10)
.add("test.sink.gsink30.context", "test") // filter out only "test"
.add("test.sink.gsink31.context", "test") // filter out only "test"
.save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test"));
MetricsSystemImpl ms = new MetricsSystemImpl("Test");
ms.start();
TestSource s1 = ms.register("s1", "s1 desc", new TestSource("s1rec"));
s1.s1.add(0);
AbstractGangliaSink gsink30 = new GangliaSink30();
gsink30.init(cb.subset("test"));
MockDatagramSocket mockds30 = new MockDatagramSocket();
GangliaMetricsTestHelper.setDatagramSocket(gsink30, mockds30);
AbstractGangliaSink gsink31 = new GangliaSink31();
gsink31.init(cb.subset("test"));
MockDatagramSocket mockds31 = new MockDatagramSocket();
GangliaMetricsTestHelper.setDatagramSocket(gsink31, mockds31);
ms.register("gsink30", "gsink30 desc", gsink30);
ms.register("gsink31", "gsink31 desc", gsink31);
ms.onTimerEvent(); // trigger something interesting
ms.stop();
// check GanfliaSink30 data
checkMetrics(mockds30.getCapturedSend());
// check GanfliaSink31 data
checkMetrics(mockds31.getCapturedSend());
}
示例2: testGangliaMetrics2
import org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricsTestHelper; //导入依赖的package包/类
@Test public void testGangliaMetrics2() throws Exception {
ConfigBuilder cb = new ConfigBuilder().add("default.period", 10)
.add("test.sink.gsink30.context", "test") // filter out only "test"
.add("test.sink.gsink31.context", "test") // filter out only "test"
.save(TestMetricsConfig.getTestFilename("hadoop-metrics2-test"));
MetricsSystemImpl ms = new MetricsSystemImpl("Test");
ms.start();
TestSource s1 = ms.register("s1", "s1 desc", new TestSource("s1rec"));
s1.c1.incr();
s1.xxx.incr();
s1.g1.set(2);
s1.yyy.incr(2);
s1.s1.add(0);
final int expectedCountFromGanglia30 = expectedMetrics.length;
final int expectedCountFromGanglia31 = 2 * expectedMetrics.length;
// Setup test for GangliaSink30
AbstractGangliaSink gsink30 = new GangliaSink30();
gsink30.init(cb.subset("test"));
MockDatagramSocket mockds30 = new MockDatagramSocket();
GangliaMetricsTestHelper.setDatagramSocket(gsink30, mockds30);
// Setup test for GangliaSink31
AbstractGangliaSink gsink31 = new GangliaSink31();
gsink31.init(cb.subset("test"));
MockDatagramSocket mockds31 = new MockDatagramSocket();
GangliaMetricsTestHelper.setDatagramSocket(gsink31, mockds31);
// register the sinks
ms.register("gsink30", "gsink30 desc", gsink30);
ms.register("gsink31", "gsink31 desc", gsink31);
ms.publishMetricsNow(); // publish the metrics
ms.stop();
// check GanfliaSink30 data
checkMetrics(mockds30.getCapturedSend(), expectedCountFromGanglia30);
// check GanfliaSink31 data
checkMetrics(mockds31.getCapturedSend(), expectedCountFromGanglia31);
}
示例3: testGangliaMetrics2
import org.apache.hadoop.metrics2.sink.ganglia.GangliaMetricsTestHelper; //导入依赖的package包/类
@Test public void testGangliaMetrics2() throws Exception {
// Setting long interval to avoid periodic publishing.
// We manually publish metrics by MeticsSystem#publishMetricsNow here.
ConfigBuilder cb = new ConfigBuilder().add("*.period", 120)
.add(testNamePrefix
+ ".sink.gsink30.context", testNamePrefix) // filter out only "test"
.add(testNamePrefix
+ ".sink.gsink31.context", testNamePrefix) // filter out only "test"
.save(TestMetricsConfig.getTestFilename("hadoop-metrics2-"
+ testNamePrefix));
MetricsSystemImpl ms = new MetricsSystemImpl(testNamePrefix);
ms.start();
TestSource s1 = ms.register("s1", "s1 desc", new TestSource("s1rec"));
s1.c1.incr();
s1.xxx.incr();
s1.g1.set(2);
s1.yyy.incr(2);
s1.s1.add(0);
final int expectedCountFromGanglia30 = expectedMetrics.length;
final int expectedCountFromGanglia31 = 2 * expectedMetrics.length;
// Setup test for GangliaSink30
AbstractGangliaSink gsink30 = new GangliaSink30();
gsink30.init(cb.subset(testNamePrefix));
MockDatagramSocket mockds30 = new MockDatagramSocket();
GangliaMetricsTestHelper.setDatagramSocket(gsink30, mockds30);
// Setup test for GangliaSink31
AbstractGangliaSink gsink31 = new GangliaSink31();
gsink31.init(cb.subset(testNamePrefix));
MockDatagramSocket mockds31 = new MockDatagramSocket();
GangliaMetricsTestHelper.setDatagramSocket(gsink31, mockds31);
// register the sinks
ms.register("gsink30", "gsink30 desc", gsink30);
ms.register("gsink31", "gsink31 desc", gsink31);
ms.publishMetricsNow(); // publish the metrics
ms.stop();
// check GanfliaSink30 data
checkMetrics(mockds30.getCapturedSend(), expectedCountFromGanglia30);
// check GanfliaSink31 data
checkMetrics(mockds31.getCapturedSend(), expectedCountFromGanglia31);
}