Search in sources :

Example 51 with MetricsCollector

use of org.apache.hadoop.metrics2.MetricsCollector in project ozone by apache.

the class ReconTaskStatusMetrics method getMetrics.

public void getMetrics(MetricsCollector collector, boolean all) {
    List<ReconTaskStatus> rows = reconTaskStatusDao.findAll();
    rows.forEach((rts) -> {
        MetricsRecordBuilder builder = collector.addRecord(SOURCE_NAME);
        builder.add(new MetricsTag(Interns.info("type", "Recon Task type"), rts.getTaskName()));
        builder.addGauge(RECORD_INFO_LAST_UPDATED_TS, rts.getLastUpdatedTimestamp());
        builder.addCounter(RECORD_INFO_LAST_UPDATED_SEQ, rts.getLastUpdatedSeqNumber());
        builder.endRecord();
    });
}
Also used : MetricsTag(org.apache.hadoop.metrics2.MetricsTag) ReconTaskStatus(org.hadoop.ozone.recon.schema.tables.pojos.ReconTaskStatus) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 52 with MetricsCollector

use of org.apache.hadoop.metrics2.MetricsCollector in project ozone by apache.

the class ProtocolMessageMetrics method getMetrics.

@Override
public void getMetrics(MetricsCollector collector, boolean all) {
    counters.forEach((key, value) -> {
        MetricsRecordBuilder builder = collector.addRecord(name);
        builder.add(new MetricsTag(Interns.info("type", "Message type"), key.toString()));
        builder.addCounter(new MetricName("counter", "Number of distinct calls"), value.longValue());
        builder.addCounter(new MetricName("time", "Sum of the duration of the calls"), elapsedTimes.get(key).longValue());
        builder.endRecord();
    });
}
Also used : MetricsTag(org.apache.hadoop.metrics2.MetricsTag) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 53 with MetricsCollector

use of org.apache.hadoop.metrics2.MetricsCollector in project ozone by apache.

the class SCMNodeMetrics method getMetrics.

/**
 * Get aggregated counter and gauge metrics.
 */
@Override
@SuppressWarnings("SuspiciousMethodCalls")
public void getMetrics(MetricsCollector collector, boolean all) {
    Map<String, Map<String, Integer>> nodeCount = managerMXBean.getNodeCount();
    Map<String, Long> nodeInfo = managerMXBean.getNodeInfo();
    /**
     * Loop over the Node map and create a metric for the cross product of all
     * Operational and health states, ie:
     *     InServiceHealthy
     *     InServiceStale
     *     ...
     *     EnteringMaintenanceHealthy
     *     ...
     */
    MetricsRecordBuilder metrics = collector.addRecord(registry.info());
    for (Map.Entry<String, Map<String, Integer>> e : nodeCount.entrySet()) {
        for (Map.Entry<String, Integer> h : e.getValue().entrySet()) {
            metrics.addGauge(Interns.info(StringUtils.camelize(e.getKey() + "_" + h.getKey() + "_nodes"), "Number of " + e.getKey() + " " + h.getKey() + " datanodes"), h.getValue());
        }
    }
    for (Map.Entry<String, Long> e : nodeInfo.entrySet()) {
        metrics.addGauge(Interns.info(e.getKey(), diskMetricDescription(e.getKey())), e.getValue());
    }
    registry.snapshot(metrics, all);
}
Also used : MutableCounterLong(org.apache.hadoop.metrics2.lib.MutableCounterLong) Map(java.util.Map) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 54 with MetricsCollector

use of org.apache.hadoop.metrics2.MetricsCollector in project hbase-filesystem by apache.

the class MetricsOSSSourceImpl method getMetrics.

/**
 * Yes this is a get function that doesn't return anything.  Thanks Hadoop for breaking all
 * expectations of java programmers.  Instead of returning anything Hadoop metrics expects
 * getMetrics to push the metrics into the collector.
 *
 * @param metricsCollector Collector to accept metrics
 * @param all              push all or only changed?
 */
@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
    MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName);
    metricsRegistry.snapshot(mrb, all);
    // source is registered in supers constructor, sometimes called before the whole initialization.
    if (metricsAdapter != null) {
        // snapshot MetricRegistry as well
        metricsAdapter.snapshotAllMetrics(registry, mrb);
    }
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Aggregations

MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)52 MetricsCollector (org.apache.hadoop.metrics2.MetricsCollector)14 Test (org.junit.Test)13 TreeMap (java.util.TreeMap)7 Map (java.util.Map)3 MetricsTag (org.apache.hadoop.metrics2.MetricsTag)3 Counter (com.codahale.metrics.Counter)2 Gauge (com.codahale.metrics.Gauge)2 Histogram (com.codahale.metrics.Histogram)2 Meter (com.codahale.metrics.Meter)2 Snapshot (com.codahale.metrics.Snapshot)2 Timer (com.codahale.metrics.Timer)2 LinkedHashMap (java.util.LinkedHashMap)2 Configuration (org.apache.hadoop.conf.Configuration)2 MetricsInfo (org.apache.hadoop.metrics2.MetricsInfo)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1