Search in sources :

Example 6 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerGroupTest method testGenerateScopeCustom.

@Test
public void testGenerateScopeCustom() throws Exception {
    Configuration cfg = new Configuration();
    cfg.setString(MetricOptions.SCOPE_NAMING_JM, "constant.<host>.foo.<host>");
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
    JobManagerMetricGroup group = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "host");
    assertArrayEquals(new String[] { "constant", "host", "foo", "host" }, group.getScopeComponents());
    assertEquals("constant.host.foo.host.name", group.getMetricIdentifier("name"));
    registry.shutdown().get();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) Test(org.junit.Test)

Example 7 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerGroupTest method testCloseClosesAll.

@Test
public void testCloseClosesAll() throws Exception {
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
    final JobManagerMetricGroup group = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "localhost");
    final JobID jid1 = new JobID();
    final JobID jid2 = new JobID();
    final String jobName1 = "testjob";
    final String jobName2 = "anotherJob";
    JobManagerJobMetricGroup jmJobGroup11 = group.addJob(jid1, jobName1);
    JobManagerJobMetricGroup jmJobGroup21 = group.addJob(jid2, jobName2);
    group.close();
    assertTrue(jmJobGroup11.isClosed());
    assertTrue(jmJobGroup21.isClosed());
    registry.shutdown().get();
}
Also used : MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 8 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerGroupTest method addAndRemoveJobs.

// ------------------------------------------------------------------------
// adding and removing jobs
// ------------------------------------------------------------------------
@Test
public void addAndRemoveJobs() throws Exception {
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
    final JobManagerMetricGroup group = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "localhost");
    final JobID jid1 = new JobID();
    final JobID jid2 = new JobID();
    final String jobName1 = "testjob";
    final String jobName2 = "anotherJob";
    JobManagerJobMetricGroup jmJobGroup11 = group.addJob(jid1, jobName1);
    JobManagerJobMetricGroup jmJobGroup12 = group.addJob(jid1, jobName1);
    JobManagerJobMetricGroup jmJobGroup21 = group.addJob(jid2, jobName2);
    assertEquals(jmJobGroup11, jmJobGroup12);
    assertEquals(2, group.numRegisteredJobMetricGroups());
    group.localCleanupAsync(jid1, Executors.directExecutor()).join();
    assertTrue(jmJobGroup11.isClosed());
    assertEquals(1, group.numRegisteredJobMetricGroups());
    group.localCleanupAsync(jid2, Executors.directExecutor()).join();
    assertTrue(jmJobGroup21.isClosed());
    assertEquals(0, group.numRegisteredJobMetricGroups());
    registry.shutdown().get();
}
Also used : MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 9 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class JobManagerGroupTest method testCreateQueryServiceMetricInfo.

@Test
public void testCreateQueryServiceMetricInfo() {
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
    JobManagerMetricGroup jm = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "host");
    QueryScopeInfo.JobManagerQueryScopeInfo info = jm.createQueryServiceMetricInfo(new DummyCharacterFilter());
    assertEquals("", info.scope);
}
Also used : QueryScopeInfo(org.apache.flink.runtime.metrics.dump.QueryScopeInfo) DummyCharacterFilter(org.apache.flink.runtime.metrics.util.DummyCharacterFilter) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) Test(org.junit.Test)

Example 10 with MetricRegistryImpl

use of org.apache.flink.runtime.metrics.MetricRegistryImpl in project flink by apache.

the class AbstractMetricGroupTest method testLogicalScopeCachingForMultipleReporters.

@Test
@SuppressWarnings("unchecked")
public void testLogicalScopeCachingForMultipleReporters() throws Exception {
    String counterName = "1";
    CollectingMetricsReporter reporter1 = new CollectingMetricsReporter(FILTER_B);
    CollectingMetricsReporter reporter2 = new CollectingMetricsReporter(FILTER_C);
    MetricRegistryImpl testRegistry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration(), Arrays.asList(ReporterSetup.forReporter("test1", reporter1), ReporterSetup.forReporter("test2", reporter2)));
    try {
        MetricGroup tmGroup = TaskManagerMetricGroup.createTaskManagerMetricGroup(testRegistry, "host", new ResourceID("id")).addGroup("B").addGroup("C");
        tmGroup.counter(counterName);
        assertEquals("Reporters were not properly instantiated", 2, testRegistry.getReporters().size());
        assertEquals("taskmanager-X-C", ((FrontMetricGroup<AbstractMetricGroup<?>>) reporter1.findAdded(counterName).group).getLogicalScope(reporter1, '-'));
        assertEquals("taskmanager,B,X", ((FrontMetricGroup<AbstractMetricGroup<?>>) reporter2.findAdded(counterName).group).getLogicalScope(reporter2, ','));
    } finally {
        testRegistry.shutdown().get();
    }
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) MetricGroup(org.apache.flink.metrics.MetricGroup) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) CollectingMetricsReporter(org.apache.flink.runtime.metrics.CollectingMetricsReporter) Test(org.junit.Test)

Aggregations

MetricRegistryImpl (org.apache.flink.runtime.metrics.MetricRegistryImpl)28 Test (org.junit.Test)24 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)17 Configuration (org.apache.flink.configuration.Configuration)15 JobID (org.apache.flink.api.common.JobID)13 MetricGroup (org.apache.flink.metrics.MetricGroup)6 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)5 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)5 QueryScopeInfo (org.apache.flink.runtime.metrics.dump.QueryScopeInfo)4 DummyCharacterFilter (org.apache.flink.runtime.metrics.util.DummyCharacterFilter)4 CharacterFilter (org.apache.flink.metrics.CharacterFilter)2 MetricRegistryConfiguration (org.apache.flink.runtime.metrics.MetricRegistryConfiguration)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 InetAddress (java.net.InetAddress)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1