Search in sources :

Example 31 with MetricsCollector

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

the class MetricsAssignmentManagerSourceImpl method getMetrics.

@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
    MetricsRecordBuilder metricsRecordBuilder = metricsCollector.addRecord(metricsName);
    metricsRegistry.snapshot(metricsRecordBuilder, all);
    if (metricsAdapter != null) {
        metricsAdapter.snapshotAllMetrics(registry, metricsRecordBuilder);
    }
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 32 with MetricsCollector

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

the class MetricsMasterProcSourceImpl method getMetrics.

@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
    MetricsRecordBuilder metricsRecordBuilder = metricsCollector.addRecord(metricsName);
    // masterWrapper can be null because this function is called inside of init.
    if (masterWrapper != null) {
        metricsRecordBuilder.addGauge(Interns.info(NUM_MASTER_WALS_NAME, NUM_MASTER_WALS_DESC), masterWrapper.getNumWALFiles());
    }
    metricsRegistry.snapshot(metricsRecordBuilder, all);
    if (metricsAdapter != null) {
        metricsAdapter.snapshotAllMetrics(registry, metricsRecordBuilder);
    }
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 33 with MetricsCollector

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

the class MetricsMasterQuotaSourceImpl method getMetrics.

@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
    MetricsRecordBuilder record = metricsCollector.addRecord(metricsRegistry.info());
    if (wrapper != null) {
        // Summarize the tables
        Map<String, Entry<Long, Long>> tableUsages = wrapper.getTableSpaceUtilization();
        String tableSummary = "[]";
        if (tableUsages != null && !tableUsages.isEmpty()) {
            tableSummary = generateJsonQuotaSummary(tableUsages.entrySet(), "table");
        }
        record.tag(Interns.info(TABLE_QUOTA_USAGE_NAME, TABLE_QUOTA_USAGE_DESC), tableSummary);
        // Summarize the namespaces
        String nsSummary = "[]";
        Map<String, Entry<Long, Long>> namespaceUsages = wrapper.getNamespaceSpaceUtilization();
        if (namespaceUsages != null && !namespaceUsages.isEmpty()) {
            nsSummary = generateJsonQuotaSummary(namespaceUsages.entrySet(), "namespace");
        }
        record.tag(Interns.info(NS_QUOTA_USAGE_NAME, NS_QUOTA_USAGE_DESC), nsSummary);
    }
    metricsRegistry.snapshot(record, all);
}
Also used : Entry(java.util.Map.Entry) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 34 with MetricsCollector

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

the class MetricsMasterSourceImpl method getMetrics.

@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
    MetricsRecordBuilder metricsRecordBuilder = metricsCollector.addRecord(metricsName);
    // metrics again.
    if (masterWrapper != null && masterWrapper.isRunning()) {
        // Pair<online region number, offline region number>
        PairOfSameType<Integer> regionNumberPair = masterWrapper.getRegionCounts();
        metricsRecordBuilder.addGauge(Interns.info(MERGE_PLAN_COUNT_NAME, MERGE_PLAN_COUNT_DESC), masterWrapper.getMergePlanCount()).addGauge(Interns.info(SPLIT_PLAN_COUNT_NAME, SPLIT_PLAN_COUNT_DESC), masterWrapper.getSplitPlanCount()).addGauge(Interns.info(MASTER_ACTIVE_TIME_NAME, MASTER_ACTIVE_TIME_DESC), masterWrapper.getActiveTime()).addGauge(Interns.info(MASTER_START_TIME_NAME, MASTER_START_TIME_DESC), masterWrapper.getStartTime()).addGauge(Interns.info(MASTER_FINISHED_INITIALIZATION_TIME_NAME, MASTER_FINISHED_INITIALIZATION_TIME_DESC), masterWrapper.getMasterInitializationTime()).addGauge(Interns.info(AVERAGE_LOAD_NAME, AVERAGE_LOAD_DESC), masterWrapper.getAverageLoad()).addGauge(Interns.info(ONLINE_REGION_COUNT_NAME, ONLINE_REGION_COUNT_DESC), regionNumberPair.getFirst()).addGauge(Interns.info(OFFLINE_REGION_COUNT_NAME, OFFLINE_REGION_COUNT_DESC), regionNumberPair.getSecond()).tag(Interns.info(LIVE_REGION_SERVERS_NAME, LIVE_REGION_SERVERS_DESC), masterWrapper.getRegionServers()).addGauge(Interns.info(NUM_REGION_SERVERS_NAME, NUMBER_OF_REGION_SERVERS_DESC), masterWrapper.getNumRegionServers()).tag(Interns.info(DEAD_REGION_SERVERS_NAME, DEAD_REGION_SERVERS_DESC), masterWrapper.getDeadRegionServers()).addGauge(Interns.info(NUM_DEAD_REGION_SERVERS_NAME, NUMBER_OF_DEAD_REGION_SERVERS_DESC), masterWrapper.getNumDeadRegionServers()).tag(Interns.info(DRAINING_REGION_SERVER_NAME, DRAINING_REGION_SERVER_DESC), masterWrapper.getDrainingRegionServers()).addGauge(Interns.info(NUM_DRAINING_REGION_SERVERS_NAME, NUMBER_OF_REGION_SERVERS_DESC), masterWrapper.getNumDrainingRegionServers()).tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC), masterWrapper.getZookeeperQuorum()).tag(Interns.info(SERVER_NAME_NAME, SERVER_NAME_DESC), masterWrapper.getServerName()).tag(Interns.info(CLUSTER_ID_NAME, CLUSTER_ID_DESC), masterWrapper.getClusterId()).tag(Interns.info(IS_ACTIVE_MASTER_NAME, IS_ACTIVE_MASTER_DESC), String.valueOf(masterWrapper.getIsActiveMaster()));
    }
    metricsRegistry.snapshot(metricsRecordBuilder, all);
    if (metricsAdapter != null) {
        metricsAdapter.snapshotAllMetrics(registry, metricsRecordBuilder);
    }
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 35 with MetricsCollector

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

the class HBaseMetrics2HadoopMetricsAdapter method snapshotAllMetrics.

/**
 * Iterates over the MetricRegistry and adds them to the {@code collector}.
 *
 * @param collector A metrics collector
 */
public void snapshotAllMetrics(MetricRegistry metricRegistry, MetricsCollector collector) {
    MetricRegistryInfo info = metricRegistry.getMetricRegistryInfo();
    MetricsRecordBuilder builder = collector.addRecord(Interns.info(info.getMetricsName(), info.getMetricsDescription()));
    builder.setContext(info.getMetricsContext());
    snapshotAllMetrics(metricRegistry, builder);
}
Also used : MetricRegistryInfo(org.apache.hadoop.hbase.metrics.MetricRegistryInfo) 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