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


Java MetricsRecordBuilder.addCounter方法代码示例

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


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

示例1: getGcUsage

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
private void getGcUsage(MetricsRecordBuilder rb) {
  long count = 0;
  long timeMillis = 0;
  for (GarbageCollectorMXBean gcBean : gcBeans) {
    long c = gcBean.getCollectionCount();
    long t = gcBean.getCollectionTime();
    MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
    rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
    count += c;
    timeMillis += t;
  }
  rb.addCounter(GcCount, count)
    .addCounter(GcTimeMillis, timeMillis);
  
  if (pauseMonitor != null) {
    rb.addCounter(GcNumWarnThresholdExceeded,
        pauseMonitor.getNumGcWarnThresholdExceeded());
    rb.addCounter(GcNumInfoThresholdExceeded,
        pauseMonitor.getNumGcInfoThresholdExceeded());
    rb.addCounter(GcTotalExtraSleepTime,
        pauseMonitor.getTotalGcExtraSleepTime());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:JvmMetrics.java

示例2: newCounter

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
MutableMetric newCounter(final Class<?> type) {
  if (isInt(type) || isLong(type)) {
    return new MutableMetric() {
      @Override public void snapshot(MetricsRecordBuilder rb, boolean all) {
        try {
          Object ret = method.invoke(obj, (Object[])null);
          if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue());
          else rb.addCounter(info, ((Long) ret).longValue());
        } catch (Exception ex) {
          LOG.error("Error invoking method "+ method.getName(), ex);
        }
      }
    };
  }
  throw new MetricsException("Unsupported counter type: "+ type.getName());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:MethodMetric.java

示例3: getMetrics

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
  StartupProgressView prog = startupProgress.createView();
  MetricsRecordBuilder builder = collector.addRecord(
    STARTUP_PROGRESS_METRICS_INFO);

  builder.addCounter(info("ElapsedTime", "overall elapsed time"),
    prog.getElapsedTime());
  builder.addGauge(info("PercentComplete", "overall percent complete"),
    prog.getPercentComplete());

  for (Phase phase: prog.getPhases()) {
    addCounter(builder, phase, "Count", " count", prog.getCount(phase));
    addCounter(builder, phase, "ElapsedTime", " elapsed time",
      prog.getElapsedTime(phase));
    addCounter(builder, phase, "Total", " total", prog.getTotal(phase));
    addGauge(builder, phase, "PercentComplete", " percent complete",
      prog.getPercentComplete(phase));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:StartupProgressMetrics.java

示例4: getGcUsage

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
private void getGcUsage(MetricsRecordBuilder rb) {
  long count = 0;
  long timeMillis = 0;
  for (GarbageCollectorMXBean gcBean : gcBeans) {
    long c = gcBean.getCollectionCount();
    long t = gcBean.getCollectionTime();
    MetricsInfo[] gcInfo = getGcInfo(gcBean.getName());
    rb.addCounter(gcInfo[0], c).addCounter(gcInfo[1], t);
    count += c;
    timeMillis += t;
  }
  rb.addCounter(GcCount, count)
    .addCounter(GcTimeMillis, timeMillis);
  
  if (pauseMonitor != null) {
    rb.addCounter(GcNumWarnThresholdExceeded,
        pauseMonitor.getNumGcWarnThreadholdExceeded());
    rb.addCounter(GcNumInfoThresholdExceeded,
        pauseMonitor.getNumGcInfoThresholdExceeded());
    rb.addCounter(GcTotalExtraSleepTime,
        pauseMonitor.getTotalGcExtraSleepTime());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:JvmMetrics.java

示例5: newCounter

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
MutableMetric newCounter(final Class<?> type) {
  if (isInt(type) || isLong(type)) {
    return new MutableMetric() {
      @Override public void snapshot(MetricsRecordBuilder rb, boolean all) {
        try {
          Object ret = method.invoke(obj, (Object[])null);
          if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue());
          else rb.addCounter(info, ((Long) ret).longValue());
        }
        catch (Exception ex) {
          LOG.error("Error invoking method "+ method.getName(), ex);
        }
      }
    };
  }
  throw new MetricsException("Unsupported counter type: "+ type.getName());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:MethodMetric.java

示例6: updateSnapshotMetrics

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
public void updateSnapshotMetrics(MetricsRecordBuilder metricsRecordBuilder) {
    final Snapshot s = sample.getSnapshot();
    metricsRecordBuilder.addCounter(Interns.info(name + NUM_OPS_METRIC_NAME, desc), count.get());

    metricsRecordBuilder.addGauge(Interns.info(name + MIN_METRIC_NAME, desc), getMin());
    metricsRecordBuilder.addGauge(Interns.info(name + MAX_METRIC_NAME, desc), getMax());
    metricsRecordBuilder.addGauge(Interns.info(name + MEAN_METRIC_NAME, desc), getMean());

    metricsRecordBuilder.addGauge(Interns.info(name + MEDIAN_METRIC_NAME, desc), s.getMedian());
    metricsRecordBuilder.addGauge(Interns.info(name + SEVENTY_FIFTH_PERCENTILE_METRIC_NAME, desc),
        s.get75thPercentile());
    metricsRecordBuilder.addGauge(Interns.info(name + NINETIETH_PERCENTILE_METRIC_NAME, desc),
        s.getValue(0.90));
    metricsRecordBuilder.addGauge(Interns.info(name + NINETY_FIFTH_PERCENTILE_METRIC_NAME, desc),
        s.get95thPercentile());
    metricsRecordBuilder.addGauge(Interns.info(name + NINETY_NINETH_PERCENTILE_METRIC_NAME, desc),
        s.get99thPercentile());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:MutableHistogram.java

示例7: snapshot

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
@Override
public void snapshot(MetricsRecordBuilder builder, boolean all) {
  if (all || changed()) {
    builder.addCounter(info(), value());
    clearChanged();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:MutableCounterLong.java

示例8: snapshot

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
void snapshot(MetricsRecordBuilder mrb, boolean ignored) {

    // If there is a close that started be double extra sure
    // that we're not getting any locks and not putting data
    // into the metrics that should be removed. So early out
    // before even getting the lock.
    if (closed.get()) {
      return;
    }

    // Grab the read
    // This ensures that removes of the metrics
    // can't happen while we are putting them back in.
    synchronized (this) {

      // It's possible that a close happened between checking
      // the closed variable and getting the lock.
      if (closed.get()) {
        return;
      }

      mrb.addGauge(
          Interns.info(
              regionNamePrefix + MetricsRegionServerSource.STORE_COUNT,
              MetricsRegionServerSource.STORE_COUNT_DESC),
          this.regionWrapper.getNumStores());
      mrb.addGauge(Interns.info(
              regionNamePrefix + MetricsRegionServerSource.STOREFILE_COUNT,
              MetricsRegionServerSource.STOREFILE_COUNT_DESC),
          this.regionWrapper.getNumStoreFiles());
      mrb.addGauge(Interns.info(
              regionNamePrefix + MetricsRegionServerSource.MEMSTORE_SIZE,
              MetricsRegionServerSource.MEMSTORE_SIZE_DESC),
          this.regionWrapper.getMemstoreSize());
      mrb.addGauge(Interns.info(
              regionNamePrefix + MetricsRegionServerSource.STOREFILE_SIZE,
              MetricsRegionServerSource.STOREFILE_SIZE_DESC),
          this.regionWrapper.getStoreFileSize());
      mrb.addCounter(Interns.info(
              regionNamePrefix + MetricsRegionSource.COMPACTIONS_COMPLETED_COUNT,
              MetricsRegionSource.COMPACTIONS_COMPLETED_DESC),
          this.regionWrapper.getNumCompactionsCompleted());
      mrb.addCounter(Interns.info(
              regionNamePrefix + MetricsRegionSource.NUM_BYTES_COMPACTED_COUNT,
              MetricsRegionSource.NUM_BYTES_COMPACTED_DESC),
          this.regionWrapper.getNumBytesCompacted());
      mrb.addCounter(Interns.info(
              regionNamePrefix + MetricsRegionSource.NUM_FILES_COMPACTED_COUNT,
              MetricsRegionSource.NUM_FILES_COMPACTED_DESC),
          this.regionWrapper.getNumFilesCompacted());
      mrb.addCounter(Interns.info(
              regionNamePrefix + MetricsRegionServerSource.READ_REQUEST_COUNT,
              MetricsRegionServerSource.READ_REQUEST_COUNT_DESC),
          this.regionWrapper.getReadRequestCount());
      mrb.addCounter(Interns.info(
              regionNamePrefix + MetricsRegionServerSource.WRITE_REQUEST_COUNT,
              MetricsRegionServerSource.WRITE_REQUEST_COUNT_DESC),
          this.regionWrapper.getWriteRequestCount());
      mrb.addCounter(Interns.info(regionNamePrefix + MetricsRegionSource.REPLICA_ID,
              MetricsRegionSource.REPLICA_ID_DESC),
          this.regionWrapper.getReplicaId());
    }
  }
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:64,代码来源:MetricsRegionSourceImpl.java

示例9: addCounter

import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
/**
 * Adds a counter with a name built by using the specified phase's name as
 * prefix and then appending the specified suffix.
 * 
 * @param builder MetricsRecordBuilder to receive counter
 * @param phase Phase to add
 * @param nameSuffix String suffix of metric name
 * @param descSuffix String suffix of metric description
 * @param value long counter value
 */
private static void addCounter(MetricsRecordBuilder builder, Phase phase,
    String nameSuffix, String descSuffix, long value) {
  MetricsInfo metricsInfo = info(phase.getName() + nameSuffix,
    phase.getDescription() + descSuffix);
  builder.addCounter(metricsInfo, value);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:StartupProgressMetrics.java


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