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


Java MetricsRegistry.add方法代码示例

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


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

示例1: ExactCounterMetric

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
/**
 * Constructor to create a new counter metric
 * @param nam         the name to publish this metric under
 * @param registry    where the metrics object will be registered
 * @param description metrics description
 * @param topN        how many 'keys' to publish metrics on 
 */
public ExactCounterMetric(final String nam, final MetricsRegistry registry, 
    final String description, int topN) {
  super(nam, description);

  this.counts = new MapMaker().makeComputingMap(
      new Function<String, Counter>() {
        @Override
        public Counter apply(String input) {
          return new Counter();
        }    
      });

  this.lock = new ReentrantReadWriteLock();
  this.topN = topN;

  if (registry != null) {
    registry.add(nam, this);      
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:ExactCounterMetric.java

示例2: MetricsHistogram

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
/**
 * Constructor to create a new histogram metric
 * @param nam           the name to publish the metric under
 * @param registry      where the metrics object will be registered
 * @param description   the metric's description
 * @param forwardBiased true if you want this histogram to give more 
 *                      weight to recent data, 
 *                      false if you want all data to have uniform weight
 */
public MetricsHistogram(final String nam, final MetricsRegistry registry, 
    final String description, boolean forwardBiased) {
  super(nam, description);

  this.min = new AtomicLong();
  this.max = new AtomicLong();
  this.sum = new AtomicLong();
  this.sample = forwardBiased ? 
      new ExponentiallyDecayingSample(DEFAULT_SAMPLE_SIZE, DEFAULT_ALPHA) 
  : new UniformSample(DEFAULT_SAMPLE_SIZE);

  this.variance =  new AtomicReference<double[]>(new double[]{-1, 0});
  this.count = new AtomicLong();

  this.clear();

  if (registry != null) {
    registry.add(nam, this);      
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:30,代码来源:MetricsHistogram.java

示例3: MetricsRate

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
public MetricsRate(final String name, final MetricsRegistry registry,
    final String description) {
  super(name, description);
  this.value = 0;
  this.prevRate = 0;
  this.ts = System.currentTimeMillis();
  registry.add(name, this);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:9,代码来源:MetricsRate.java

示例4: copyMinusHBaseMetrics

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
private static MetricsRegistry copyMinusHBaseMetrics(final MetricsRegistry mr) {
  MetricsRegistry copy = new MetricsRegistry();
  for (MetricsBase metric : mr.getMetricsList()) {
    if (metric instanceof MetricsRate || metric instanceof MetricsString ||
        metric instanceof MetricsHistogram || metric instanceof ExactCounterMetric) {
      continue;
    }
    copy.add(metric.getName(), metric);
  }
  return copy;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:12,代码来源:MetricsMBeanBase.java

示例5: ExactCounterMetric

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
/**
   * Constructor to create a new counter metric
   * @param nam         the name to publish this metric under
   * @param registry    where the metrics object will be registered
   * @param description metrics description
   * @param topN        how many 'keys' to publish metrics on
   */
public ExactCounterMetric(final String nam, final MetricsRegistry registry, 
    final String description, int topN) {
  super(nam, description);

  this.lock = new ReentrantReadWriteLock();
  this.topN = topN;

  if (registry != null) {
    registry.add(nam, this);      
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:19,代码来源:ExactCounterMetric.java

示例6: copyMinusHBaseMetrics

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
private static MetricsRegistry copyMinusHBaseMetrics(final MetricsRegistry mr) {
  MetricsRegistry copy = new MetricsRegistry();
  for (MetricsBase metric : mr.getMetricsList()) {
    if (metric instanceof MetricsRate || metric instanceof MetricsString) {
      continue;
    }
    copy.add(metric.getName(), metric);
  }
  return copy;
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:11,代码来源:MetricsMBeanBase.java

示例7: MetricsString

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
public MetricsString(final String name, final MetricsRegistry registry, 
    final String value) {
  super(name, NO_DESCRIPTION);
  this.value = value;
  registry.add(name, this);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:7,代码来源:MetricsString.java

示例8: testMetricsMBeanBaseHistogram

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
public void testMetricsMBeanBaseHistogram()
    throws ReflectionException, AttributeNotFoundException, MBeanException {
  MetricsRegistry mr = new MetricsRegistry();
  MetricsHistogram histo = mock(MetricsHistogram.class);
  Snapshot snap = mock(Snapshot.class);

  //Set up the mocks
  String histoName = "MockHisto";
  when(histo.getName()).thenReturn(histoName);
  when(histo.getCount()).thenReturn(20l);
  when(histo.getMin()).thenReturn(1l);
  when(histo.getMax()).thenReturn(999l);
  when(histo.getMean()).thenReturn(500.2);
  when(histo.getStdDev()).thenReturn(1.2);
  when(histo.getSnapshot()).thenReturn(snap);

  when(snap.getMedian()).thenReturn(490.0);
  when(snap.get75thPercentile()).thenReturn(550.0);
  when(snap.get95thPercentile()).thenReturn(900.0);
  when(snap.get99thPercentile()).thenReturn(990.0);

  mr.add("myTestHisto", histo);

  MetricsMBeanBase mBeanBase = new MetricsMBeanBase(mr, "test");

  assertEquals(new Long(20), mBeanBase
      .getAttribute(histoName + MetricsHistogram.NUM_OPS_METRIC_NAME));
  assertEquals(new Long(1), mBeanBase
      .getAttribute(histoName + MetricsHistogram.MIN_METRIC_NAME));
  assertEquals(new Long(999), mBeanBase
      .getAttribute(histoName + MetricsHistogram.MAX_METRIC_NAME));
  assertEquals(new Float(500.2), mBeanBase
      .getAttribute(histoName + MetricsHistogram.MEAN_METRIC_NAME));
  assertEquals(new Float(1.2), mBeanBase
      .getAttribute(histoName + MetricsHistogram.STD_DEV_METRIC_NAME));

  assertEquals(new Float(490.0), mBeanBase
      .getAttribute(histoName + MetricsHistogram.MEDIAN_METRIC_NAME));
  assertEquals(new Float(550.0), mBeanBase
      .getAttribute(histoName + MetricsHistogram.SEVENTY_FIFTH_PERCENTILE_METRIC_NAME));
  assertEquals(new Float(900.0), mBeanBase
      .getAttribute(histoName + MetricsHistogram.NINETY_FIFTH_PERCENTILE_METRIC_NAME));
  assertEquals(new Float(990.0), mBeanBase
      .getAttribute(histoName + MetricsHistogram.NINETY_NINETH_PERCENTILE_METRIC_NAME));
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:46,代码来源:TestMetricsMBeanBase.java

示例9: MetricsString

import org.apache.hadoop.metrics.util.MetricsRegistry; //导入方法依赖的package包/类
public MetricsString(final String name, final String description, 
    final MetricsRegistry registry, final String value) {
  super(name, description);
  this.value = value;
  registry.add(name, this);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:7,代码来源:MetricsString.java


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