Search in sources :

Example 1 with JvmMetricsInfo

use of org.apache.hadoop.metrics2.source.JvmMetricsInfo in project hadoop by apache.

the class TestJvmMetrics method testPresence.

@Test
public void testPresence() {
    pauseMonitor = new JvmPauseMonitor();
    pauseMonitor.init(new Configuration());
    pauseMonitor.start();
    JvmMetrics jvmMetrics = new JvmMetrics("test", "test");
    jvmMetrics.setPauseMonitor(pauseMonitor);
    MetricsRecordBuilder rb = getMetrics(jvmMetrics);
    MetricsCollector mc = rb.parent();
    verify(mc).addRecord(JvmMetrics);
    verify(rb).tag(ProcessName, "test");
    verify(rb).tag(SessionId, "test");
    for (JvmMetricsInfo info : JvmMetricsInfo.values()) {
        if (info.name().startsWith("Mem"))
            verify(rb).addGauge(eq(info), anyFloat());
        else if (info.name().startsWith("Gc"))
            verify(rb).addCounter(eq(info), anyLong());
        else if (info.name().startsWith("Threads"))
            verify(rb).addGauge(eq(info), anyInt());
        else if (info.name().startsWith("Log"))
            verify(rb).addCounter(eq(info), anyLong());
    }
}
Also used : MetricsCollector(org.apache.hadoop.metrics2.MetricsCollector) Configuration(org.apache.hadoop.conf.Configuration) JvmMetricsInfo(org.apache.hadoop.metrics2.source.JvmMetricsInfo) JvmPauseMonitor(org.apache.hadoop.util.JvmPauseMonitor) MetricsRecordBuilder(org.apache.hadoop.metrics2.MetricsRecordBuilder) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)1 MetricsCollector (org.apache.hadoop.metrics2.MetricsCollector)1 MetricsRecordBuilder (org.apache.hadoop.metrics2.MetricsRecordBuilder)1 JvmMetricsInfo (org.apache.hadoop.metrics2.source.JvmMetricsInfo)1 JvmPauseMonitor (org.apache.hadoop.util.JvmPauseMonitor)1 Test (org.junit.Test)1