Class MetricsAssertHelperImpl

java.lang.Object
org.apache.hadoop.hbase.test.MetricsAssertHelperImpl
All Implemented Interfaces:
MetricsAssertHelper

public class MetricsAssertHelperImpl extends Object implements MetricsAssertHelper
A helper class that will allow tests to get into hadoop2's metrics2 values.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
     
    class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Map<String,Long>
     
    private Map<String,Number>
     
    private Map<String,String>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    assertCounter(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a counter exists and that it's value is equal to the expected value.
    void
    assertCounterGt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a counter exists and that it's value is greater than the given value.
    void
    assertCounterLt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a counter exists and that it's value is less than the given value.
    void
    assertGauge(String name, double expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a gauge exists and that it's value is equal to the expected value.
    void
    assertGauge(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a gauge exists and that it's value is equal to the expected value.
    void
    assertGaugeGt(String name, double expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a gauge exists and it's value is greater than a given value
    void
    assertGaugeGt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a gauge exists and it's value is greater than a given value
    void
    assertGaugeLt(String name, double expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a gauge exists and it's value is less than a given value
    void
    assertGaugeLt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a gauge exists and it's value is less than a given value
    void
    assertTag(String name, String expected, org.apache.hadoop.hbase.metrics.BaseSource source)
    Assert that a tag exists and has a given value.
    private String
     
    boolean
    checkCounterExists(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
    Check if a dynamic counter exists.
    boolean
    checkGaugeExists(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
    Check if a gauge exists.
    long
    getCounter(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
    Get the value of a counter.
    double
    getGaugeDouble(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
    Get the value of a gauge as a double.
    long
    getGaugeLong(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
    Get the value of a gauge as a long.
    private void
    getMetrics(org.apache.hadoop.hbase.metrics.BaseSource source)
     
    void
    Init helper.
    private void
     
    toDebugString(org.apache.hadoop.hbase.metrics.BaseSource source)
    Generates a representation of all metrics exported by the given source.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • init

      public void init()
      Description copied from interface: MetricsAssertHelper
      Init helper. This method will make sure that the metrics system is set up for tests.
      Specified by:
      init in interface MetricsAssertHelper
    • assertTag

      public void assertTag(String name, String expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a tag exists and has a given value.
      Specified by:
      assertTag in interface MetricsAssertHelper
      Parameters:
      name - The name of the tag.
      expected - The expected value
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertGauge

      public void assertGauge(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a gauge exists and that it's value is equal to the expected value.
      Specified by:
      assertGauge in interface MetricsAssertHelper
      Parameters:
      name - The name of the gauge
      expected - The expected value of the gauge.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertGaugeGt

      public void assertGaugeGt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a gauge exists and it's value is greater than a given value
      Specified by:
      assertGaugeGt in interface MetricsAssertHelper
      Parameters:
      name - The name of the gauge
      expected - Value that the gauge is expected to be greater than
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertGaugeLt

      public void assertGaugeLt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a gauge exists and it's value is less than a given value
      Specified by:
      assertGaugeLt in interface MetricsAssertHelper
      Parameters:
      name - The name of the gauge
      expected - Value that the gauge is expected to be less than
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertGauge

      public void assertGauge(String name, double expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a gauge exists and that it's value is equal to the expected value.
      Specified by:
      assertGauge in interface MetricsAssertHelper
      Parameters:
      name - The name of the gauge
      expected - The expected value of the gauge.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertGaugeGt

      public void assertGaugeGt(String name, double expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a gauge exists and it's value is greater than a given value
      Specified by:
      assertGaugeGt in interface MetricsAssertHelper
      Parameters:
      name - The name of the gauge
      expected - Value that the gauge is expected to be greater than
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertGaugeLt

      public void assertGaugeLt(String name, double expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a gauge exists and it's value is less than a given value
      Specified by:
      assertGaugeLt in interface MetricsAssertHelper
      Parameters:
      name - The name of the gauge
      expected - Value that the gauge is expected to be less than
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertCounter

      public void assertCounter(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a counter exists and that it's value is equal to the expected value.
      Specified by:
      assertCounter in interface MetricsAssertHelper
      Parameters:
      name - The name of the counter.
      expected - The expected value
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertCounterGt

      public void assertCounterGt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a counter exists and that it's value is greater than the given value.
      Specified by:
      assertCounterGt in interface MetricsAssertHelper
      Parameters:
      name - The name of the counter.
      expected - The value the counter is expected to be greater than.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • assertCounterLt

      public void assertCounterLt(String name, long expected, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Assert that a counter exists and that it's value is less than the given value.
      Specified by:
      assertCounterLt in interface MetricsAssertHelper
      Parameters:
      name - The name of the counter.
      expected - The value the counter is expected to be less than.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
    • getCounter

      public long getCounter(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Get the value of a counter.
      Specified by:
      getCounter in interface MetricsAssertHelper
      Parameters:
      name - name of the counter.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
      Returns:
      long value of the counter.
    • checkCounterExists

      public boolean checkCounterExists(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Check if a dynamic counter exists.
      Specified by:
      checkCounterExists in interface MetricsAssertHelper
      Parameters:
      name - name of the counter.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
      Returns:
      boolean true if counter metric exists.
    • checkGaugeExists

      public boolean checkGaugeExists(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Check if a gauge exists.
      Specified by:
      checkGaugeExists in interface MetricsAssertHelper
      Parameters:
      name - name of the gauge.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
      Returns:
      boolean true if gauge metric exists.
    • getGaugeDouble

      public double getGaugeDouble(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Get the value of a gauge as a double.
      Specified by:
      getGaugeDouble in interface MetricsAssertHelper
      Parameters:
      name - name of the gauge.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
      Returns:
      double value of the gauge.
    • getGaugeLong

      public long getGaugeLong(String name, org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Get the value of a gauge as a long.
      Specified by:
      getGaugeLong in interface MetricsAssertHelper
      Parameters:
      name - name of the gauge.
      source - The BaseSourceBaseSource that will provide the tags, gauges, and counters.
      Returns:
      long value of the gauge.
    • toDebugString

      public String toDebugString(org.apache.hadoop.hbase.metrics.BaseSource source)
      Description copied from interface: MetricsAssertHelper
      Generates a representation of all metrics exported by the given source.
      Specified by:
      toDebugString in interface MetricsAssertHelper
      Parameters:
      source - The BaseSource that will provide the metrics.
      Returns:
      A representation of the metrics as a String.
    • reset

      private void reset()
    • getMetrics

      private void getMetrics(org.apache.hadoop.hbase.metrics.BaseSource source)
    • canonicalizeMetricName