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


Java MsInfo类代码示例

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


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

示例1: appendPrefix

import org.apache.hadoop.metrics2.impl.MsInfo; //导入依赖的package包/类
@InterfaceAudience.Private
public void appendPrefix(MetricsRecord record, StringBuilder sb) {
  String contextName = record.context();
  Collection<MetricsTag> tags = record.tags();
  if (useTagsMap.containsKey(contextName)) {
    Set<String> useTags = useTagsMap.get(contextName);
    for (MetricsTag t : tags) {
      if (useTags == null || useTags.contains(t.name())) {

        // the context is always skipped here because it is always added
        
        // the hostname is always skipped to avoid case-mismatches 
        // from different DNSes.

        if (t.info() != MsInfo.Context && t.info() != MsInfo.Hostname && t.value() != null) {
          sb.append('.').append(t.name()).append('=').append(t.value());
        }
      }
    }
  }          
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:22,代码来源:GangliaSink30.java

示例2: testHybrid

import org.apache.hadoop.metrics2.impl.MsInfo; //导入依赖的package包/类
@Test public void testHybrid() {
  HybridMetrics metrics = new HybridMetrics();
  MetricsSource source = MetricsAnnotations.makeSource(metrics);

  assertSame(metrics, source);
  metrics.C0.incr();
  MetricsRecordBuilder rb = getMetrics(source);
  MetricsCollector collector = rb.parent();

  verify(collector).addRecord("foo");
  verify(collector).addRecord("bar");
  verify(collector).addRecord(info("HybridMetrics", "HybridMetrics"));
  verify(rb).setContext("foocontext");
  verify(rb).addCounter(info("C1", "C1 desc"), 1);
  verify(rb).setContext("barcontext");
  verify(rb).addGauge(info("G1", "G1 desc"), 1);
  verify(rb).add(tag(MsInfo.Context, "hybrid"));
  verify(rb).addCounter(info("C0", "C0 desc"), 1);
  verify(rb).addGauge(info("G0", "G0"), 0);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:TestMetricsAnnotations.java

示例3: testClasses

import org.apache.hadoop.metrics2.impl.MsInfo; //导入依赖的package包/类
@Test public void testClasses() {
  MetricsRecordBuilder rb = getMetrics(
      MetricsAnnotations.makeSource(new MyMetrics3()));
  MetricsCollector collector = rb.parent();

  verify(collector).addRecord(info("MyMetrics3", "My metrics"));
  verify(rb).add(tag(MsInfo.Context, "foo"));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:TestMetricsAnnotations.java

示例4: putMetrics

import org.apache.hadoop.metrics2.impl.MsInfo; //导入依赖的package包/类
@Override
public void putMetrics(MetricsRecord record) {

  String hn = hostName;
  String ctx = record.context();
  String sn = serviceName;

  for (MetricsTag tag : record.tags()) {
    if (tag.info().name().equals(MsInfo.Hostname.name())
        && tag.value() != null) {
      hn = tag.value();
    } else if (tag.info().name().equals(MsInfo.Context.name())
        && tag.value() != null) {
      ctx = tag.value();
    } else if (tag.info().name().equals(MsInfo.ProcessName.name())
        && tag.value() != null) {
      sn = tag.value();
    }
  }

  StringBuilder buf = new StringBuilder();
  if (!skipHostname && hn != null) {
    int idx = hn.indexOf(".");
    if (idx == -1) {
      buf.append(hn).append(PERIOD);
    } else {
      buf.append(hn.substring(0, idx)).append(PERIOD);
    }
  }
  buf.append(sn).append(PERIOD);
  buf.append(ctx).append(PERIOD);
  buf.append(record.name().replaceAll("\\.", "-")).append(PERIOD);

  // Collect datapoints.
  for (AbstractMetric metric : record.metrics()) {
    String type = null;
    if (metric.type().equals(MetricType.COUNTER)) {
      type = "c";
    } else if (metric.type().equals(MetricType.GAUGE)) {
      type = "g";
    }
    StringBuilder line = new StringBuilder();
    line.append(buf.toString())
        .append(metric.name().replace(' ', '_'))
        .append(":")
        .append(metric.value())
        .append("|")
        .append(type);
    writeMetric(line.toString());
  }

}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:53,代码来源:StatsDSink.java

示例5: setContext

import org.apache.hadoop.metrics2.impl.MsInfo; //导入依赖的package包/类
/**
 * Set the metrics context tag
 * @param name of the context
 * @return the registry itself as a convenience
 */
public MetricsRegistry setContext(String name) {
  return tag(MsInfo.Context, name, true);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:MetricsRegistry.java

示例6: setContext

import org.apache.hadoop.metrics2.impl.MsInfo; //导入依赖的package包/类
/**
 * Set the metrics context tag
 * @param name of the context
 * @return the registry itself as a convenience
 */
public DynamicMetricsRegistry setContext(String name) {
  return tag(MsInfo.Context, name, true);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:DynamicMetricsRegistry.java


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