当前位置: 首页>>代码示例>>Java>>正文


Java GangliaSink30类代码示例

本文整理汇总了Java中org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30的典型用法代码示例。如果您正苦于以下问题:Java GangliaSink30类的具体用法?Java GangliaSink30怎么用?Java GangliaSink30使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GangliaSink30类属于org.apache.hadoop.metrics2.sink.ganglia包,在下文中一共展示了GangliaSink30类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTagsForPrefix

import org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30; //导入依赖的package包/类
@Test
public void testTagsForPrefix() throws Exception {
  ConfigBuilder cb = new ConfigBuilder()
    .add("test.sink.ganglia.tagsForPrefix.all", "*")
    .add("test.sink.ganglia.tagsForPrefix.some", "NumActiveSinks, " +
            "NumActiveSources")
    .add("test.sink.ganglia.tagsForPrefix.none", "");
  GangliaSink30 sink = new GangliaSink30();
  sink.init(cb.subset("test.sink.ganglia"));

  List<MetricsTag> tags = new ArrayList<MetricsTag>();
  tags.add(new MetricsTag(MsInfo.Context, "all"));
  tags.add(new MetricsTag(MsInfo.NumActiveSources, "foo"));
  tags.add(new MetricsTag(MsInfo.NumActiveSinks, "bar"));
  tags.add(new MetricsTag(MsInfo.NumAllSinks, "haa"));
  tags.add(new MetricsTag(MsInfo.Hostname, "host"));
  Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
  MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 1, tags, metrics);

  StringBuilder sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar.NumAllSinks=haa", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "some"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "none"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "nada"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:39,代码来源:TestGangliaMetrics.java

示例2: testTagsForPrefix

import org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30; //导入依赖的package包/类
@Test
public void testTagsForPrefix() throws Exception {
  ConfigBuilder cb = new ConfigBuilder()
    .add("test.sink.ganglia.tagsForPrefix.all", "*")
    .add("test.sink.ganglia.tagsForPrefix.some", "NumActiveSinks, NumActiveSources")
    .add("test.sink.ganglia.tagsForPrefix.none", "");
  GangliaSink30 sink = new GangliaSink30();
  sink.init(cb.subset("test.sink.ganglia"));

  List<MetricsTag> tags = new ArrayList<MetricsTag>();
  tags.add(new MetricsTag(MsInfo.Context, "all"));
  tags.add(new MetricsTag(MsInfo.NumActiveSources, "foo"));
  tags.add(new MetricsTag(MsInfo.NumActiveSinks, "bar"));
  tags.add(new MetricsTag(MsInfo.NumAllSinks, "haa"));
  tags.add(new MetricsTag(MsInfo.Hostname, "host"));
  Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
  MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 1, tags, metrics);

  StringBuilder sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar.NumAllSinks=haa", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "some"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "none"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "nada"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:38,代码来源:TestGangliaMetrics.java

示例3: testTagsForPrefix

import org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30; //导入依赖的package包/类
@Test
public void testTagsForPrefix() throws Exception {
  ConfigBuilder cb = new ConfigBuilder()
      .add(testNamePrefix + ".sink.ganglia.tagsForPrefix.all", "*")
      .add(testNamePrefix + ".sink.ganglia.tagsForPrefix.some",
        "NumActiveSinks, " + "NumActiveSources")
      .add(testNamePrefix + ".sink.ganglia.tagsForPrefix.none", "");
  GangliaSink30 sink = new GangliaSink30();
  sink.init(cb.subset(testNamePrefix + ".sink.ganglia"));

  List<MetricsTag> tags = new ArrayList<MetricsTag>();
  tags.add(new MetricsTag(MsInfo.Context, "all"));
  tags.add(new MetricsTag(MsInfo.NumActiveSources, "foo"));
  tags.add(new MetricsTag(MsInfo.NumActiveSinks, "bar"));
  tags.add(new MetricsTag(MsInfo.NumAllSinks, "haa"));
  tags.add(new MetricsTag(MsInfo.Hostname, "host"));
  Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
  MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 1, tags, metrics);

  StringBuilder sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar.NumAllSinks=haa", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "some"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals(".NumActiveSources=foo.NumActiveSinks=bar", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "none"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());

  tags.set(0, new MetricsTag(MsInfo.Context, "nada"));
  sb = new StringBuilder();
  sink.appendPrefix(record, sb);
  assertEquals("", sb.toString());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:39,代码来源:TestGangliaMetrics.java

示例4: testGangliaMetrics2

import org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30; //导入依赖的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());
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:33,代码来源:TestGangliaMetrics.java

示例5: testGangliaMetrics2

import org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30; //导入依赖的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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:44,代码来源:TestGangliaMetrics.java

示例6: testGangliaMetrics2

import org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30; //导入依赖的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);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:49,代码来源:TestGangliaMetrics.java


注:本文中的org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。