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


Java MetricsHistogram.getSnapshot方法代码示例

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


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

示例1: appendHistogram

import org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram; //导入方法依赖的package包/类
private StringBuilder appendHistogram(StringBuilder sb, 
    MetricsHistogram histogram) {
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "Mean", 
      StringUtils.limitDecimalTo2(histogram.getMean()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "Count", 
      StringUtils.limitDecimalTo2(histogram.getCount()));
  final Snapshot s = histogram.getSnapshot();
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "Median", 
      StringUtils.limitDecimalTo2(s.getMedian()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "75th", 
      StringUtils.limitDecimalTo2(s.get75thPercentile()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "95th", 
      StringUtils.limitDecimalTo2(s.get95thPercentile()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "99th", 
      StringUtils.limitDecimalTo2(s.get99thPercentile()));
  sb = Strings.appendKeyValue(sb, 
      histogram.getName() + "999th", 
      StringUtils.limitDecimalTo2(s.get999thPercentile()));
  return sb;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:RegionServerMetrics.java

示例2: testSnapshotPercentiles

import org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram; //导入方法依赖的package包/类
@Test
public void testSnapshotPercentiles() {
  final MetricsHistogram h = new MetricsHistogram("testHistogram", null);
  final long[] data = genRandomData(h);

  final Snapshot s = h.getSnapshot();

  assertPercentile(data, 50, s.getMedian());
  assertPercentile(data, 75, s.get75thPercentile());
  assertPercentile(data, 95, s.get95thPercentile());
  assertPercentile(data, 98, s.get98thPercentile());
  assertPercentile(data, 99, s.get99thPercentile());
  assertPercentile(data, 99.9, s.get999thPercentile());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:15,代码来源:TestMetricsHistogram.java

示例3: testRandom

import org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram; //导入方法依赖的package包/类
@Test
public void testRandom() {
  final Random r = new Random();
  final MetricsHistogram h = new MetricsHistogram("testHistogram", null);

  final long[] data = new long[1000];

  for (int i = 0; i < data.length; i++) {
    data[i] = (long) (r.nextGaussian() * 10000.0);
    h.update(data[i]);
  }

  final Snapshot s = h.getSnapshot();
  Arrays.sort(data);

  // as long as the histogram chooses an item with index N+/-slop, accept it
  final int slop = 20;

  // make sure the median, 75th percentile and 95th percentile are good
  final int medianIndex = data.length / 2;
  final long minAcceptableMedian = data[safeIndex(medianIndex - slop, 
      data.length)];
  final long maxAcceptableMedian = data[safeIndex(medianIndex + slop, 
      data.length)];
  Assert.assertTrue(s.getMedian() >= minAcceptableMedian 
      && s.getMedian() <= maxAcceptableMedian);

  final int seventyFifthIndex = (int) (data.length * 0.75);
  final long minAcceptableseventyFifth = data[safeIndex(seventyFifthIndex 
      - slop, data.length)];
  final long maxAcceptableseventyFifth = data[safeIndex(seventyFifthIndex 
      + slop, data.length)];
  Assert.assertTrue(s.get75thPercentile() >= minAcceptableseventyFifth 
      && s.get75thPercentile() <= maxAcceptableseventyFifth);

  final int ninetyFifthIndex = (int) (data.length * 0.95);
  final long minAcceptableninetyFifth = data[safeIndex(ninetyFifthIndex 
      - slop, data.length)];
  final long maxAcceptableninetyFifth = data[safeIndex(ninetyFifthIndex 
      + slop, data.length)];
  Assert.assertTrue(s.get95thPercentile() >= minAcceptableninetyFifth 
      && s.get95thPercentile() <= maxAcceptableninetyFifth);

}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:45,代码来源:TestMetricsHistogram.java


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