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


Java ConfigBuilder类代码示例

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


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

示例1: includeOnlyShouldOnlyIncludeMatched

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * Filters should handle white-listing correctly
 */
@Test public void includeOnlyShouldOnlyIncludeMatched() {
  SubsetConfiguration wl = new ConfigBuilder()
      .add("p.include", "foo")
      .add("p.include.tags", "foo:f").subset("p");
  shouldAccept(wl, "foo");
  shouldAccept(wl, Arrays.asList(tag("bar", "", ""),
                                 tag("foo", "", "f")), new boolean[] {false, true});
  shouldAccept(wl, mockMetricsRecord("foo", Arrays.asList(
    tag("bar", "", ""), tag("foo", "", "f"))));
  shouldReject(wl, "bar");
  shouldReject(wl, Arrays.asList(tag("bar", "", "")));
  shouldReject(wl, Arrays.asList(tag("foo", "", "boo")));
  shouldReject(wl, mockMetricsRecord("bar", Arrays.asList(
    tag("foo", "", "f"))));
  shouldReject(wl, mockMetricsRecord("foo", Arrays.asList(
    tag("bar", "", ""))));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:TestPatternFilter.java

示例2: excludeOnlyShouldOnlyExcludeMatched

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * 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"))));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:TestPatternFilter.java

示例3: shouldAcceptUnmatchedWhenBothAreConfigured

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * Filters should accepts unmatched item when both include and
 * exclude patterns are present.
 */
@Test public void shouldAcceptUnmatchedWhenBothAreConfigured() {
  SubsetConfiguration c = new ConfigBuilder()
      .add("p.include", "foo")
      .add("p.include.tags", "foo:f")
      .add("p.exclude", "bar")
      .add("p.exclude.tags", "bar:b").subset("p");
  shouldAccept(c, "foo");
  shouldAccept(c, Arrays.asList(tag("foo", "", "f")));
  shouldAccept(c, mockMetricsRecord("foo", Arrays.asList(
    tag("foo", "", "f"))));
  shouldReject(c, "bar");
  shouldReject(c, Arrays.asList(tag("bar", "", "b")));
  shouldReject(c, mockMetricsRecord("bar", Arrays.asList(
    tag("foo", "", "f"))));
  shouldReject(c, mockMetricsRecord("foo", Arrays.asList(
    tag("bar", "", "b"))));
  shouldAccept(c, "foobar");
  shouldAccept(c, Arrays.asList(tag("foobar", "", "")));
  shouldAccept(c, mockMetricsRecord("foobar", Arrays.asList(
    tag("foobar", "", ""))));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:TestPatternFilter.java

示例4: includeOnlyShouldOnlyIncludeMatched

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * Filters should handle white-listing correctly
 */
@Test public void includeOnlyShouldOnlyIncludeMatched() {
  SubsetConfiguration wl = new ConfigBuilder()
      .add("p.include", "foo")
      .add("p.include.tags", "foo:f").subset("p");
  shouldAccept(wl, "foo");
  shouldAccept(wl, Arrays.asList(tag("bar", "", ""),
                                 tag("foo", "", "f")));
  shouldAccept(wl, mockMetricsRecord("foo", Arrays.asList(
    tag("bar", "", ""), tag("foo", "", "f"))));
  shouldReject(wl, "bar");
  shouldReject(wl, Arrays.asList(tag("bar", "", "")));
  shouldReject(wl, Arrays.asList(tag("foo", "", "boo")));
  shouldReject(wl, mockMetricsRecord("bar", Arrays.asList(
    tag("foo", "", "f"))));
  shouldReject(wl, mockMetricsRecord("foo", Arrays.asList(
    tag("bar", "", ""))));
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:21,代码来源:TestPatternFilter.java

示例5: excludeOnlyShouldOnlyExcludeMatched

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * 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")));
  shouldReject(bl, mockMetricsRecord("foo", Arrays.asList(
    tag("bar", "", ""))));
  shouldReject(bl, mockMetricsRecord("bar", Arrays.asList(
    tag("bar", "", ""), tag("foo", "", "f"))));
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:20,代码来源:TestPatternFilter.java

示例6: testShouldCreateDatagramSocketByDefault

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
@Test
public void testShouldCreateDatagramSocketByDefault() throws Exception {
    SubsetConfiguration conf = new ConfigBuilder()
            .subset("test.sink.ganglia");

    GangliaSink30 gangliaSink = new GangliaSink30();
    gangliaSink.init(conf);
    DatagramSocket socket = gangliaSink.getDatagramSocket();
    assertFalse("Did not create DatagramSocket", socket == null || socket instanceof MulticastSocket);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:TestGangliaSink.java

示例7: testShouldCreateDatagramSocketIfMulticastIsDisabled

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
@Test
public void testShouldCreateDatagramSocketIfMulticastIsDisabled() throws Exception {
    SubsetConfiguration conf = new ConfigBuilder()
            .add("test.sink.ganglia.multicast", false)
            .subset("test.sink.ganglia");
    GangliaSink30 gangliaSink = new GangliaSink30();
    gangliaSink.init(conf);
    DatagramSocket socket = gangliaSink.getDatagramSocket();
    assertFalse("Did not create DatagramSocket", socket == null || socket instanceof MulticastSocket);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:TestGangliaSink.java

示例8: testShouldCreateMulticastSocket

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
@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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:TestGangliaSink.java

示例9: testShouldSetMulticastSocketTtl

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
@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);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:14,代码来源:TestGangliaSink.java

示例10: initMetricsSystem

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * Set up the metrics system, start it, and return it.
 * @param path the base path for the sink
 * @param ignoreErrors whether the sink should ignore errors
 * @param allowAppend whether the sink is allowed to append to existing files
 * @param useSecureParams whether to set the principal and keytab properties
 * @return the org.apache.hadoop.metrics2.MetricsSystem
 */
protected MetricsSystem initMetricsSystem(String path, boolean ignoreErrors,
    boolean allowAppend, boolean useSecureParams) {
  // If the prefix is not lower case, the metrics system won't be able to
  // read any of the properties.
  String prefix = methodName.getMethodName().toLowerCase();

  ConfigBuilder builder = new ConfigBuilder().add("*.period", 10000)
      .add(prefix + ".sink.mysink0.class", MockSink.class.getName())
      .add(prefix + ".sink.mysink0.basepath", path)
      .add(prefix + ".sink.mysink0.source", "testsrc")
      .add(prefix + ".sink.mysink0.context", "test1")
      .add(prefix + ".sink.mysink0.ignore-error", ignoreErrors)
      .add(prefix + ".sink.mysink0.allow-append", allowAppend);

  if (useSecureParams) {
      builder.add(prefix + ".sink.mysink0.keytab-key", SINK_KEYTAB_FILE_KEY)
      .add(prefix + ".sink.mysink0.principal-key", SINK_PRINCIPAL_KEY);
  }

  builder.save(TestMetricsConfig.getTestFilename("hadoop-metrics2-" + prefix));

  MetricsSystemImpl ms = new MetricsSystemImpl(prefix);

  ms.start();

  return ms;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:36,代码来源:RollingFileSystemSinkTestBase.java

示例11: emptyConfigShouldAccept

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * 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"))));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:TestPatternFilter.java

示例12: includeShouldOverrideExclude

import org.apache.hadoop.metrics2.impl.ConfigBuilder; //导入依赖的package包/类
/**
 * Include patterns should take precedence over exclude patterns
 */
@Test public void includeShouldOverrideExclude() {
  SubsetConfiguration c = new ConfigBuilder()
      .add("p.include", "foo")
      .add("p.include.tags", "foo:f")
      .add("p.exclude", "foo")
      .add("p.exclude.tags", "foo:f").subset("p");
  shouldAccept(c, "foo");
  shouldAccept(c, Arrays.asList(tag("foo", "", "f")));
  shouldAccept(c, mockMetricsRecord("foo", Arrays.asList(
    tag("foo", "", "f"))));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:TestPatternFilter.java


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