Search in sources :

Example 1 with Meter

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

the class TestMetricRegistryImpl method testMeter.

@Test
public void testMeter() {
    Meter meter = registry.meter("mymeter");
    assertNotNull(meter);
    meter.mark();
}
Also used : Meter(org.apache.hadoop.hbase.metrics.Meter) Test(org.junit.Test)

Example 2 with Meter

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

the class HBaseMetrics2HadoopMetricsAdapter method snapshotAllMetrics.

/**
   * Iterates over the MetricRegistry and adds them to the {@code builder}.
   *
   * @param builder A record builder
   */
public void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsRecordBuilder builder) {
    Map<String, Metric> metrics = metricRegistry.getMetrics();
    for (Map.Entry<String, Metric> e : metrics.entrySet()) {
        // Always capitalize the name
        String name = StringUtils.capitalize(e.getKey());
        Metric metric = e.getValue();
        if (metric instanceof Gauge) {
            addGauge(name, (Gauge<?>) metric, builder);
        } else if (metric instanceof Counter) {
            addCounter(name, (Counter) metric, builder);
        } else if (metric instanceof Histogram) {
            addHistogram(name, (Histogram) metric, builder);
        } else if (metric instanceof Meter) {
            addMeter(name, (Meter) metric, builder);
        } else if (metric instanceof Timer) {
            addTimer(name, (Timer) metric, builder);
        } else {
            LOG.info("Ignoring unknown Metric class " + metric.getClass().getName());
        }
    }
}
Also used : MutableHistogram(org.apache.hadoop.metrics2.lib.MutableHistogram) Histogram(org.apache.hadoop.hbase.metrics.Histogram) Counter(org.apache.hadoop.hbase.metrics.Counter) Timer(org.apache.hadoop.hbase.metrics.Timer) Meter(org.apache.hadoop.hbase.metrics.Meter) Metric(org.apache.hadoop.hbase.metrics.Metric) Map(java.util.Map) Gauge(org.apache.hadoop.hbase.metrics.Gauge)

Aggregations

Meter (org.apache.hadoop.hbase.metrics.Meter)2 Map (java.util.Map)1 Counter (org.apache.hadoop.hbase.metrics.Counter)1 Gauge (org.apache.hadoop.hbase.metrics.Gauge)1 Histogram (org.apache.hadoop.hbase.metrics.Histogram)1 Metric (org.apache.hadoop.hbase.metrics.Metric)1 Timer (org.apache.hadoop.hbase.metrics.Timer)1 MutableHistogram (org.apache.hadoop.metrics2.lib.MutableHistogram)1 Test (org.junit.Test)1