Package org.apache.hadoop.hbase.test
Class MetricsAssertHelperImpl
java.lang.Object
org.apache.hadoop.hbase.test.MetricsAssertHelperImpl
- All Implemented Interfaces:
MetricsAssertHelper
A helper class that will allow tests to get into hadoop2's metrics2 values.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 valuevoid
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 valuevoid
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 valuevoid
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 valuevoid
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()
Init helper.private void
reset()
toDebugString
(org.apache.hadoop.hbase.metrics.BaseSource source) Generates a representation of all metrics exported by the givensource
.
-
Field Details
-
tags
-
gauges
-
counters
-
-
Constructor Details
-
MetricsAssertHelperImpl
public MetricsAssertHelperImpl()
-
-
Method Details
-
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 interfaceMetricsAssertHelper
-
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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the tag.expected
- The expected valuesource
- 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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the gaugeexpected
- 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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the gaugeexpected
- Value that the gauge is expected to be greater thansource
- 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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the gaugeexpected
- Value that the gauge is expected to be less thansource
- 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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the gaugeexpected
- 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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the gaugeexpected
- Value that the gauge is expected to be greater thansource
- 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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the gaugeexpected
- Value that the gauge is expected to be less thansource
- 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 interfaceMetricsAssertHelper
- Parameters:
name
- The name of the counter.expected
- The expected valuesource
- 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 interfaceMetricsAssertHelper
- 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 interfaceMetricsAssertHelper
- 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
Description copied from interface:MetricsAssertHelper
Get the value of a counter.- Specified by:
getCounter
in interfaceMetricsAssertHelper
- Parameters:
name
- name of the counter.source
- The BaseSourceBaseSource
that will provide the tags, gauges, and counters.- Returns:
- long value of the counter.
-
checkCounterExists
Description copied from interface:MetricsAssertHelper
Check if a dynamic counter exists.- Specified by:
checkCounterExists
in interfaceMetricsAssertHelper
- 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
Description copied from interface:MetricsAssertHelper
Check if a gauge exists.- Specified by:
checkGaugeExists
in interfaceMetricsAssertHelper
- 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
Description copied from interface:MetricsAssertHelper
Get the value of a gauge as a double.- Specified by:
getGaugeDouble
in interfaceMetricsAssertHelper
- Parameters:
name
- name of the gauge.source
- The BaseSourceBaseSource
that will provide the tags, gauges, and counters.- Returns:
- double value of the gauge.
-
getGaugeLong
Description copied from interface:MetricsAssertHelper
Get the value of a gauge as a long.- Specified by:
getGaugeLong
in interfaceMetricsAssertHelper
- Parameters:
name
- name of the gauge.source
- The BaseSourceBaseSource
that will provide the tags, gauges, and counters.- Returns:
- long value of the gauge.
-
toDebugString
Description copied from interface:MetricsAssertHelper
Generates a representation of all metrics exported by the givensource
.- Specified by:
toDebugString
in interfaceMetricsAssertHelper
- Parameters:
source
- TheBaseSource
that will provide the metrics.- Returns:
- A representation of the metrics as a String.
-
reset
-
getMetrics
-
canonicalizeMetricName
-