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


Java AbstractMetric类代码示例

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


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

示例1: putMetrics

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

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

示例3: get

import org.apache.hadoop.metrics2.AbstractMetric; //导入依赖的package包/类
MBeanInfo get() {
  curRecNo = 0;
  for (MetricsRecordImpl rec : recs) {
    for (MetricsTag t : rec.tags()) {
      attrs.add(newAttrInfo("tag."+ t.name(), t.description(),
                "java.lang.String"));
    }
    for (AbstractMetric m : rec.metrics()) {
      m.visit(this);
    }
    ++curRecNo;
  }
  MetricsSystemImpl.LOG.debug(attrs);
  MBeanAttributeInfo[] attrsArray = new MBeanAttributeInfo[attrs.size()];
  return new MBeanInfo(name, description, attrs.toArray(attrsArray),
                       null, null, null); // no ops/ctors/notifications
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:MBeanInfoBuilder.java

示例4: updateAttrCache

import org.apache.hadoop.metrics2.AbstractMetric; //导入依赖的package包/类
private int updateAttrCache() {
  LOG.debug("Updating attr cache...");
  int recNo = 0;
  int numMetrics = 0;
  for (MetricsRecordImpl record : lastRecs) {
    for (MetricsTag t : record.tags()) {
      setAttrCacheTag(t, recNo);
      ++numMetrics;
    }
    for (AbstractMetric m : record.metrics()) {
      setAttrCacheMetric(m, recNo);
      ++numMetrics;
    }
    ++recNo;
  }
  LOG.debug("Done. # tags & metrics="+ numMetrics);
  return numMetrics;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:MetricsSourceAdapter.java

示例5: metrics

import org.apache.hadoop.metrics2.AbstractMetric; //导入依赖的package包/类
@Override public Iterable<AbstractMetric> metrics() {
  return new Iterable<AbstractMetric>() {
    final Iterator<AbstractMetric> it = delegate.metrics().iterator();
    @Override public Iterator<AbstractMetric> iterator() {
      return new AbstractIterator<AbstractMetric>() {
        @Override public AbstractMetric computeNext() {
          while (it.hasNext()) {
            AbstractMetric next = it.next();
            if (filter.accepts(next.name())) {
              return next;
            }
          }
          return endOfData();
        }
      };
    }
  };
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:MetricsRecordFiltered.java

示例6: putMetrics

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

示例7: getLatestMetricValue

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

示例8: putMetrics

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

示例9: testCloseAndWrite

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