Package org.apache.hadoop.hbase.metrics.histogram

Examples of org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram


        if (metric instanceof MetricsRate) {
          return ((MetricsRate) metric).getPreviousIntervalValue();
        } else if (metric instanceof MetricsString) {
          return ((MetricsString)metric).getValue();
        } else if (metric instanceof MetricsHistogram)  {
          MetricsHistogram hist = (MetricsHistogram) metric;
          if (name.endsWith(MetricsHistogram.NUM_OPS_METRIC_NAME)) {
            return hist.getCount();
          } else if (name.endsWith(MetricsHistogram.MIN_METRIC_NAME)) {
            return hist.getMin();
          } else if (name.endsWith(MetricsHistogram.MAX_METRIC_NAME)) {
            return hist.getMax();
          } else if (name.endsWith(MetricsHistogram.MEAN_METRIC_NAME)) {
            return (float) hist.getMean();
          } else if (name.endsWith(MetricsHistogram.STD_DEV_METRIC_NAME)) {
            return (float) hist.getStdDev();
          } else if (name.endsWith(MetricsHistogram.MEDIAN_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.getMedian();
          } else if (name.endsWith(MetricsHistogram.SEVENTY_FIFTH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get75thPercentile();
          } else if (name.endsWith(MetricsHistogram.NINETY_FIFTH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get95thPercentile();
          } else if (name.endsWith(MetricsHistogram.NINETY_NINETH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get99thPercentile();
          }

        } else {
          LOG.warn( String.format("unknown metrics type %s for attribute %s",
View Full Code Here


@Category(SmallTests.class)
public class TestMetricsHistogram {

  @Test
  public void testBasicUniform() {
    MetricsHistogram h = new MetricsHistogram("testHistogram", null);

    for (int i = 0; i < 100; i++) {
      h.update(i);
    }

    Assert.assertEquals(100, h.getCount());
    Assert.assertEquals(0, h.getMin());
    Assert.assertEquals(99, h.getMax());
  }
View Full Code Here

  }
 
  @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;

View Full Code Here

        if (metric instanceof MetricsRate) {
          return ((MetricsRate) metric).getPreviousIntervalValue();
        } else if (metric instanceof MetricsString) {
          return ((MetricsString)metric).getValue();
        } else if (metric instanceof MetricsHistogram)  {
          MetricsHistogram hist = (MetricsHistogram) metric;
          if (name.endsWith(MetricsHistogram.NUM_OPS_METRIC_NAME)) {
            return hist.getCount();
          } else if (name.endsWith(MetricsHistogram.MIN_METRIC_NAME)) {
            return hist.getMin();
          } else if (name.endsWith(MetricsHistogram.MAX_METRIC_NAME)) {
            return hist.getMax();
          } else if (name.endsWith(MetricsHistogram.MEAN_METRIC_NAME)) {
            return (float) hist.getMean();
          } else if (name.endsWith(MetricsHistogram.STD_DEV_METRIC_NAME)) {
            return (float) hist.getStdDev();
          } else if (name.endsWith(MetricsHistogram.MEDIAN_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.getMedian();
          } else if (name.endsWith(MetricsHistogram.SEVENTY_FIFTH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get75thPercentile();
          } else if (name.endsWith(MetricsHistogram.NINETY_FIFTH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get95thPercentile();
          } else if (name.endsWith(MetricsHistogram.NINETY_NINETH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get99thPercentile();
          }

        } else {
          LOG.warn( String.format("unknown metrics type %s for attribute %s",
View Full Code Here

@Category(SmallTests.class)
public class TestMetricsHistogram {

  @Test
  public void testBasicUniform() {
    MetricsHistogram h = new MetricsHistogram("testHistogram", null);

    for (int i = 0; i < 100; i++) {
      h.update(i);
    }

    Assert.assertEquals(100, h.getCount());
    Assert.assertEquals(0, h.getMin());
    Assert.assertEquals(99, h.getMax());
    Assert.assertEquals(49.5d, h.getMean(), 0.01);
  }
View Full Code Here

    Assert.assertEquals(49.5d, h.getMean(), 0.01);
  }

  @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());
View Full Code Here

    assertPercentile(data, 99.9, s.get999thPercentile());
  }

  @Test
  public void testPushMetric() {
    final MetricsHistogram h = new MetricsHistogram("testHistogram", null);
    genRandomData(h);

    MetricsRecord mr = mock(MetricsRecord.class);
    h.pushMetric(mr);
   
    verify(mr).setMetric("testHistogram_num_ops", 10000L);
    verify(mr).setMetric(eq("testHistogram_min"), anyLong());
    verify(mr).setMetric(eq("testHistogram_max"), anyLong());
    verify(mr).setMetric(eq("testHistogram_mean"), anyFloat());
View Full Code Here

        if (metric instanceof MetricsRate) {
          return ((MetricsRate) metric).getPreviousIntervalValue();
        } else if (metric instanceof MetricsString) {
          return ((MetricsString)metric).getValue();
        } else if (metric instanceof MetricsHistogram)  {
          MetricsHistogram hist = (MetricsHistogram) metric;
          if (name.endsWith(MetricsHistogram.NUM_OPS_METRIC_NAME)) {
            return hist.getCount();
          } else if (name.endsWith(MetricsHistogram.MIN_METRIC_NAME)) {
            return hist.getMin();
          } else if (name.endsWith(MetricsHistogram.MAX_METRIC_NAME)) {
            return hist.getMax();
          } else if (name.endsWith(MetricsHistogram.MEAN_METRIC_NAME)) {
            return (float) hist.getMean();
          } else if (name.endsWith(MetricsHistogram.STD_DEV_METRIC_NAME)) {
            return (float) hist.getStdDev();
          } else if (name.endsWith(MetricsHistogram.MEDIAN_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.getMedian();
          } else if (name.endsWith(MetricsHistogram.SEVENTY_FIFTH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get75thPercentile();
          } else if (name.endsWith(MetricsHistogram.NINETY_FIFTH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get95thPercentile();
          } else if (name.endsWith(MetricsHistogram.NINETY_NINETH_PERCENTILE_METRIC_NAME)) {
            Snapshot s = hist.getSnapshot();
            return (float) s.get99thPercentile();
          }

        } else {
          LOG.warn( String.format("unknown metrics type %s for attribute %s",
View Full Code Here

  }

  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);
View Full Code Here

@Category(SmallTests.class)
public class TestMetricsHistogram {

  @Test
  public void testBasicUniform() {
    MetricsHistogram h = new MetricsHistogram("testHistogram", null);

    for (int i = 0; i < 100; i++) {
      h.update(i);
    }

    Assert.assertEquals(100, h.getCount());
    Assert.assertEquals(0, h.getMin());
    Assert.assertEquals(99, h.getMax());
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.metrics.histogram.MetricsHistogram

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.