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


Java MetricsRecord类代码示例

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


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

示例1: putMetrics

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的package包/类
@Override
public void putMetrics(MetricsRecord record) {
  writer.print(record.timestamp());
  writer.print(" ");
  writer.print(record.context());
  writer.print(".");
  writer.print(record.name());
  String separator = ": ";
  for (MetricsTag tag : record.tags()) {
    writer.print(separator);
    separator = ", ";
    writer.print(tag.name());
    writer.print("=");
    writer.print(tag.value());
  }
  for (AbstractMetric metric : record.metrics()) {
    writer.print(separator);
    separator = ", ";
    writer.print(metric.name());
    writer.print("=");
    writer.print(metric.value());
  }
  writer.println();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:25,代码来源:FileSink.java

示例2: appendPrefix

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的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

示例3: update

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的package包/类
/**
 * Update the cache and return the current cached record
 * @param mr the update record
 * @param includingTags cache tag values (for later lookup by name) if true
 * @return the updated cache record
 */
public Record update(MetricsRecord mr, boolean includingTags) {
  String name = mr.name();
  RecordCache recordCache = map.get(name);
  if (recordCache == null) {
    recordCache = new RecordCache();
    map.put(name, recordCache);
  }
  Collection<MetricsTag> tags = mr.tags();
  Record record = recordCache.get(tags);
  if (record == null) {
    record = new Record();
    recordCache.put(tags, record);
  }
  for (AbstractMetric m : mr.metrics()) {
    record.metrics.put(m.name(), m);
  }
  if (includingTags) {
    // mostly for some sinks that include tags as part of a dense schema
    for (MetricsTag t : mr.tags()) {
      record.tags.put(t.name(), t.value());
    }
  }
  return record;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:31,代码来源:MetricsCache.java

示例4: putMetrics

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的package包/类
@Override
public void putMetrics(MetricsRecord record) {
  final String prefix = "threadSourceRec";
  if (record.name().startsWith(prefix)) {
    final int recordNumber = Integer.parseInt(
        record.name().substring(prefix.length()));
    ArrayList<String> names = new ArrayList<String>();
    for (AbstractMetric m : record.metrics()) {
      if (m.name().equalsIgnoreCase("g1")) {
        collected[recordNumber].set(m.value().longValue());
        return;
      }
      names.add(m.name());
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TestMetricsSystemImpl.java

示例5: checkMetricsRecords

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的package包/类
private void checkMetricsRecords(List<MetricsRecord> recs) {
  LOG.debug(recs);
  MetricsRecord r = recs.get(0);
  assertEquals("name", "s1rec", r.name());
  assertEquals("tags", new MetricsTag[] {
    tag(MsInfo.Context, "test"),
    tag(MsInfo.Hostname, hostname)}, r.tags());
  assertEquals("metrics", MetricsLists.builder("")
    .addCounter(info("C1", "C1 desc"), 1L)
    .addGauge(info("G1", "G1 desc"), 2L)
    .addCounter(info("S1NumOps", "Number of ops for s1"), 1L)
    .addGauge(info("S1AvgTime", "Average time for s1"), 0.0)
    .metrics(), r.metrics());

  r = recs.get(1);
  assertTrue("NumActiveSinks should be 3", Iterables.contains(r.metrics(),
             new MetricGaugeInt(MsInfo.NumActiveSinks, 3)));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:TestMetricsSystemImpl.java

示例6: getLatestMetricValue

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的package包/类
public Number getLatestMetricValue(String metricName, Number defaultValue)
    throws IndexOutOfBoundsException{
  boolean found = false;
  Number ret = null;
  for (MetricsRecord currentRecord : allMetrics) {
    // First check if this record is coming for my file system.
    if (wasGeneratedByMe(currentRecord)) {
      for (AbstractMetric currentMetric : currentRecord.metrics()) {
        if (currentMetric.name().equalsIgnoreCase(metricName)) {
          found = true;
          ret = currentMetric.value();
          break;
        }
      }
    }
  }
  if (!found) {
    if (defaultValue != null) {
      return defaultValue;
    }
    throw new IndexOutOfBoundsException(metricName);
  }
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:AzureBlobStorageTestAccount.java

示例7: putMetrics

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的package包/类
/**
 * add a metrics record in the sink
 *
 * @param record the record to add
 */
@Override
public void putMetrics(MetricsRecord record) {
  // let us do this only once, otherwise
  // our count could go out of sync.
  if (count == 0) {
    for (AbstractMetric m : record.metrics()) {
      if (nameMap.contains(m.name())) {
        count++;
      }
    }

    for (MetricsTag t : record.tags()) {
      if (nameMap.contains(t.name())) {
        count++;
      }
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:24,代码来源:TestDataNodeFSDataSetSink.java

示例8: testCloseAndWrite

import org.apache.hadoop.metrics2.MetricsRecord; //导入依赖的package包/类
@Test(expected=MetricsException.class)
public void testCloseAndWrite() throws IOException {
  GraphiteSink sink = new GraphiteSink();
  List<MetricsTag> tags = new ArrayList<MetricsTag>();
  tags.add(new MetricsTag(MsInfo.Context, "all"));
  tags.add(new MetricsTag(MsInfo.Hostname, "host"));
  Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
  metrics.add(makeMetric("foo1", 1.25));
  metrics.add(makeMetric("foo2", 2.25));
  MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 10000, tags, metrics);

  OutputStreamWriter writer = mock(OutputStreamWriter.class);

  Whitebox.setInternalState(sink, "writer", writer);
  sink.close();
  sink.putMetrics(record);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:18,代码来源:TestGraphiteMetrics.java


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