Java源码示例:org.apache.hadoop.metrics2.impl.MsInfo

示例1
@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());
        }
      }
    }
  }
}
 
示例2
@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());
        }
      }
    }
  }          
}
 
示例3
@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);
}
 
示例4
@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());
        }
      }
    }
  }          
}
 
示例5
@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);
}
 
示例6
@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"));
}
 
示例7
@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"));
}
 
示例8
/**
 * 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);
}
 
示例9
/**
 * 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);
}
 
示例10
/**
 * 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);
}