Search in sources :

Example 1 with TopConf

use of org.apache.hadoop.hdfs.server.namenode.top.TopConf 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

Configuration (org.apache.hadoop.conf.Configuration)1 TopConf (org.apache.hadoop.hdfs.server.namenode.top.TopConf)1 TopMetrics (org.apache.hadoop.hdfs.server.namenode.top.metrics.TopMetrics)1 MetricsCollector (org.apache.hadoop.metrics2.MetricsCollector)1 MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)1 Test (org.junit.Test)1