Search in sources :

Example 6 with MetricsSystemImpl

use of org.apache.hadoop.metrics2.impl.MetricsSystemImpl in project hadoop by apache.

the class TestQueueMetrics method testMetricsCache.

@Test
public void testMetricsCache() {
    MetricsSystem ms = new MetricsSystemImpl("cache");
    ms.start();
    try {
        String p1 = "root1";
        String leafQueueName = "root1.leaf";
        QueueMetrics p1Metrics = QueueMetrics.forQueue(ms, p1, null, true, conf);
        Queue parentQueue1 = make(stub(Queue.class).returning(p1Metrics).from.getMetrics());
        QueueMetrics metrics = QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);
        Assert.assertNotNull("QueueMetrics for A shoudn't be null", metrics);
        // Re-register to check for cache hit, shouldn't blow up metrics-system...
        // also, verify parent-metrics
        QueueMetrics alterMetrics = QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);
        Assert.assertNotNull("QueueMetrics for alterMetrics shoudn't be null", alterMetrics);
    } finally {
        ms.shutdown();
    }
}
Also used : MetricsSystem(org.apache.hadoop.metrics2.MetricsSystem) MetricsSystemImpl(org.apache.hadoop.metrics2.impl.MetricsSystemImpl) Test(org.junit.Test)

Example 7 with MetricsSystemImpl

use of org.apache.hadoop.metrics2.impl.MetricsSystemImpl in project hadoop by apache.

the class TestQueueMetrics method setUp.

@Before
public void setUp() {
    ms = new MetricsSystemImpl();
    QueueMetrics.clearQueueMetrics();
}
Also used : MetricsSystemImpl(org.apache.hadoop.metrics2.impl.MetricsSystemImpl) Before(org.junit.Before)

Example 8 with MetricsSystemImpl

use of org.apache.hadoop.metrics2.impl.MetricsSystemImpl in project hadoop by apache.

the class AzureFileSystemMetricsSystem method fileSystemStarted.

public static synchronized void fileSystemStarted() {
    if (numFileSystems == 0) {
        instance = new MetricsSystemImpl();
        instance.init("azure-file-system");
    }
    numFileSystems++;
}
Also used : MetricsSystemImpl(org.apache.hadoop.metrics2.impl.MetricsSystemImpl)

Example 9 with MetricsSystemImpl

use of org.apache.hadoop.metrics2.impl.MetricsSystemImpl in project hadoop by apache.

the class TestFSQueueMetrics method setUp.

@Before
public void setUp() {
    ms = new MetricsSystemImpl();
    QueueMetrics.clearQueueMetrics();
}
Also used : MetricsSystemImpl(org.apache.hadoop.metrics2.impl.MetricsSystemImpl) Before(org.junit.Before)

Example 10 with MetricsSystemImpl

use of org.apache.hadoop.metrics2.impl.MetricsSystemImpl in project hadoop by apache.

the class TestContainerMetrics method testContainerMetricsFinished.

@Test
public void testContainerMetricsFinished() throws InterruptedException {
    MetricsSystemImpl system = new MetricsSystemImpl();
    system.init("test");
    ApplicationId appId = ApplicationId.newInstance(1234, 3);
    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 4);
    ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1);
    ContainerMetrics metrics1 = ContainerMetrics.forContainer(system, containerId1, 1, 0);
    ContainerId containerId2 = ContainerId.newContainerId(appAttemptId, 2);
    ContainerMetrics metrics2 = ContainerMetrics.forContainer(system, containerId2, 1, 0);
    ContainerId containerId3 = ContainerId.newContainerId(appAttemptId, 3);
    ContainerMetrics metrics3 = ContainerMetrics.forContainer(system, containerId3, 1, 0);
    metrics1.finished();
    metrics2.finished();
    system.sampleMetrics();
    system.sampleMetrics();
    Thread.sleep(100);
    // verify metrics1 is unregistered
    assertTrue(metrics1 != ContainerMetrics.forContainer(system, containerId1, 1, 0));
    // verify metrics2 is unregistered
    assertTrue(metrics2 != ContainerMetrics.forContainer(system, containerId2, 1, 0));
    // verify metrics3 is still registered
    assertTrue(metrics3 == ContainerMetrics.forContainer(system, containerId3, 1, 0));
    // YARN-5190: move stop() to the end to verify registering containerId1 and
    // containerId2 won't get MetricsException thrown.
    system.stop();
    system.shutdown();
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) ApplicationAttemptId(org.apache.hadoop.yarn.api.records.ApplicationAttemptId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) MetricsSystemImpl(org.apache.hadoop.metrics2.impl.MetricsSystemImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 MetricsSystemImpl (org.apache.hadoop.metrics2.impl.MetricsSystemImpl)8 MetricsSystem (org.apache.hadoop.metrics2.MetricsSystem)7 DefaultMetricsSystem (org.apache.hadoop.metrics2.lib.DefaultMetricsSystem)5 MetricsSink (org.apache.hadoop.metrics2.MetricsSink)4 MetricsRecord (org.apache.hadoop.metrics2.MetricsRecord)3 MetricsSource (org.apache.hadoop.metrics2.MetricsSource)2 ConfigBuilder (org.apache.hadoop.metrics2.impl.ConfigBuilder)2 Before (org.junit.Before)2 Predicate (com.google.common.base.Predicate)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Pattern (java.util.regex.Pattern)1 Nullable (javax.annotation.Nullable)1 AbstractMetric (org.apache.hadoop.metrics2.AbstractMetric)1 AbstractGangliaSink (org.apache.hadoop.metrics2.sink.ganglia.AbstractGangliaSink)1 GangliaSink30 (org.apache.hadoop.metrics2.sink.ganglia.GangliaSink30)1 GangliaSink31 (org.apache.hadoop.metrics2.sink.ganglia.GangliaSink31)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1