Search in sources :

Example 21 with MetricsCollector

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

the class DecayRpcScheduler method getMetrics.

@Override
public void getMetrics(MetricsCollector collector, boolean all) {
    // Metrics2 interface to act as a Metric source
    try {
        MetricsRecordBuilder rb = collector.addRecord(getClass().getName()).setContext(namespace);
        addDecayedCallVolume(rb);
        addUniqueIdentityCount(rb);
        addTopNCallerSummary(rb);
        addAvgResponseTimePerPriority(rb);
        addCallVolumePerPriority(rb);
        addRawCallVolume(rb);
    } catch (Exception e) {
        LOG.warn("Exception thrown while metric collection. Exception : " + e.getMessage());
    }
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 22 with MetricsCollector

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

the class MetricsSystemImpl method getMetrics.

@Override
public synchronized void getMetrics(MetricsCollector builder, boolean all) {
    MetricsRecordBuilder rb = builder.addRecord(MS_NAME).addGauge(MsInfo.NumActiveSources, sources.size()).addGauge(MsInfo.NumAllSources, allSources.size()).addGauge(MsInfo.NumActiveSinks, sinks.size()).addGauge(MsInfo.NumAllSinks, allSinks.size());
    for (MetricsSinkAdapter sa : sinks.values()) {
        sa.snapshot(rb, all);
    }
    registry.snapshot(rb, all);
}
Also used : MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder)

Example 23 with MetricsCollector

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

the class TestMetricsAnnotations method testClasses.

@Test
public void testClasses() {
    MetricsRecordBuilder rb = getMetrics(MetricsAnnotations.makeSource(new MyMetrics3()));
    MetricsCollector collector = rb.parent();
    verify(collector).addRecord(info("MyMetrics3", "My metrics"));
    verify(rb).add(tag(MsInfo.Context, "foo"));
}
Also used : MetricsCollector(org.apache.hadoop.metrics2.MetricsCollector) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Example 24 with MetricsCollector

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

the class TestTopMetrics method testPresence.

@Test
public void testPresence() {
    Configuration conf = new Configuration();
    TopConf topConf = new TopConf(conf);
    TopMetrics topMetrics = new TopMetrics(conf, topConf.nntopReportingPeriodsMs);
    // Dummy command
    topMetrics.report("test", "listStatus");
    topMetrics.report("test", "listStatus");
    topMetrics.report("test", "listStatus");
    MetricsRecordBuilder rb = getMetrics(topMetrics);
    MetricsCollector mc = rb.parent();
    verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=60000");
    verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=300000");
    verify(mc).addRecord(TOPMETRICS_METRICS_SOURCE_NAME + ".windowMs=1500000");
    verify(rb, times(3)).addCounter(Interns.info("op=listStatus.TotalCount", "Total operation count"), 3L);
    verify(rb, times(3)).addCounter(Interns.info("op=*.TotalCount", "Total operation count"), 3L);
    verify(rb, times(3)).addCounter(Interns.info("op=listStatus." + "user=test.count", "Total operations performed by user"), 3L);
}
Also used : MetricsCollector(org.apache.hadoop.metrics2.MetricsCollector) Configuration(org.apache.hadoop.conf.Configuration) TopMetrics(org.apache.hadoop.hdfs.server.namenode.top.metrics.TopMetrics) TopConf(org.apache.hadoop.hdfs.server.namenode.top.TopConf) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Aggregations

MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)23 MetricsCollector (org.apache.hadoop.metrics2.MetricsCollector)6 Test (org.junit.Test)4 Configuration (org.apache.hadoop.conf.Configuration)2 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 MetricRegistryInfo (org.apache.hadoop.hbase.metrics.MetricRegistryInfo)1 Phase (org.apache.hadoop.hdfs.server.namenode.startupprogress.Phase)1 StartupProgressView (org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgressView)1 TopConf (org.apache.hadoop.hdfs.server.namenode.top.TopConf)1 TopMetrics (org.apache.hadoop.hdfs.server.namenode.top.metrics.TopMetrics)1 MetricsSource (org.apache.hadoop.metrics2.MetricsSource)1 MetricsTag (org.apache.hadoop.metrics2.MetricsTag)1 JvmMetricsInfo (org.apache.hadoop.metrics2.source.JvmMetricsInfo)1 JvmPauseMonitor (org.apache.hadoop.util.JvmPauseMonitor)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1