Search in sources :

Example 6 with Counter

use of org.apache.hadoop.hbase.metrics.Counter in project hbase by apache.

the class TestMetricRegistryImpl method testDoubleRegister.

@Test
public void testDoubleRegister() {
    Gauge g1 = registry.register("mygauge", () -> 42L);
    Gauge g2 = registry.register("mygauge", () -> 52L);
    // second gauge is ignored if it exists
    assertEquals(g1, g2);
    Optional<Metric> metric = registry.get("mygauge");
    assertTrue(metric.isPresent());
    assertEquals(42L, (long) ((Gauge<Long>) metric.get()).getValue());
    Counter c1 = registry.counter("mycounter");
    Counter c2 = registry.counter("mycounter");
    assertEquals(c1, c2);
}
Also used : Counter(org.apache.hadoop.hbase.metrics.Counter) Metric(org.apache.hadoop.hbase.metrics.Metric) Gauge(org.apache.hadoop.hbase.metrics.Gauge) Test(org.junit.Test)

Aggregations

Counter (org.apache.hadoop.hbase.metrics.Counter)6 Metric (org.apache.hadoop.hbase.metrics.Metric)6 Test (org.junit.Test)4 MetricRegistry (org.apache.hadoop.hbase.metrics.MetricRegistry)3 MetricRegistryInfo (org.apache.hadoop.hbase.metrics.MetricRegistryInfo)3 Admin (org.apache.hadoop.hbase.client.Admin)2 Connection (org.apache.hadoop.hbase.client.Connection)2 Gauge (org.apache.hadoop.hbase.metrics.Gauge)2 Map (java.util.Map)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 Put (org.apache.hadoop.hbase.client.Put)1 Table (org.apache.hadoop.hbase.client.Table)1 Histogram (org.apache.hadoop.hbase.metrics.Histogram)1 Meter (org.apache.hadoop.hbase.metrics.Meter)1 Timer (org.apache.hadoop.hbase.metrics.Timer)1 MutableHistogram (org.apache.hadoop.metrics2.lib.MutableHistogram)1