Search in sources :

Example 21 with MetricRegistryImpl

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

the class InternalOperatorGroupTest method testGenerateScopeCustom.

@Test
public void testGenerateScopeCustom() throws Exception {
    Configuration cfg = new Configuration();
    cfg.setString(MetricOptions.SCOPE_NAMING_OPERATOR, "<tm_id>.<job_id>.<task_id>.<operator_name>.<operator_id>");
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
    try {
        String tmID = "test-tm-id";
        JobID jid = new JobID();
        JobVertexID vertexId = new JobVertexID();
        OperatorID operatorID = new OperatorID();
        String operatorName = "operatorName";
        InternalOperatorMetricGroup operatorGroup = TaskManagerMetricGroup.createTaskManagerMetricGroup(registry, "theHostName", new ResourceID(tmID)).addJob(jid, "myJobName").addTask(vertexId, new ExecutionAttemptID(), "aTaskname", 13, 2).getOrAddOperator(operatorID, operatorName);
        assertArrayEquals(new String[] { tmID, jid.toString(), vertexId.toString(), operatorName, operatorID.toString() }, operatorGroup.getScopeComponents());
        assertEquals(String.format("%s.%s.%s.%s.%s.name", tmID, jid, vertexId, operatorName, operatorID), operatorGroup.getMetricIdentifier("name"));
    } finally {
        registry.shutdown().get();
    }
}
Also used : ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) Configuration(org.apache.flink.configuration.Configuration) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 22 with MetricRegistryImpl

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

the class TaskManagerJobGroupTest method testGenerateScopeCustomWildcard.

@Test
public void testGenerateScopeCustomWildcard() throws Exception {
    Configuration cfg = new Configuration();
    cfg.setString(MetricOptions.SCOPE_NAMING_TM, "peter.<tm_id>");
    cfg.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "*.some-constant.<job_id>");
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
    JobID jid = new JobID();
    TaskManagerMetricGroup tmGroup = TaskManagerMetricGroup.createTaskManagerMetricGroup(registry, "theHostName", new ResourceID("test-tm-id"));
    JobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName");
    assertArrayEquals(new String[] { "peter", "test-tm-id", "some-constant", jid.toString() }, jmGroup.getScopeComponents());
    assertEquals("peter.test-tm-id.some-constant." + jid + ".name", jmGroup.getMetricIdentifier("name"));
    registry.shutdown().get();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 23 with MetricRegistryImpl

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

the class TaskMetricGroupTest method testGenerateScopeWilcard.

@Test
public void testGenerateScopeWilcard() throws Exception {
    Configuration cfg = new Configuration();
    cfg.setString(MetricOptions.SCOPE_NAMING_TASK, "*.<task_attempt_id>.<subtask_index>");
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(cfg));
    ExecutionAttemptID executionId = new ExecutionAttemptID();
    TaskManagerMetricGroup tmGroup = TaskManagerMetricGroup.createTaskManagerMetricGroup(registry, "theHostName", new ResourceID("test-tm-id"));
    TaskMetricGroup taskGroup = tmGroup.addJob(new JobID(), "myJobName").addTask(new JobVertexID(), executionId, "aTaskName", 13, 1);
    assertArrayEquals(new String[] { "theHostName", "taskmanager", "test-tm-id", "myJobName", executionId.toString(), "13" }, taskGroup.getScopeComponents());
    assertEquals("theHostName.taskmanager.test-tm-id.myJobName." + executionId + ".13.name", taskGroup.getMetricIdentifier("name"));
    registry.shutdown().get();
}
Also used : ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) Configuration(org.apache.flink.configuration.Configuration) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 24 with MetricRegistryImpl

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

the class JobManagerGroupTest method testGenerateScopeDefault.

// ------------------------------------------------------------------------
// scope name tests
// ------------------------------------------------------------------------
@Test
public void testGenerateScopeDefault() throws Exception {
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.defaultMetricRegistryConfiguration());
    JobManagerMetricGroup group = JobManagerMetricGroup.createJobManagerMetricGroup(registry, "localhost");
    assertArrayEquals(new String[] { "localhost", "jobmanager" }, group.getScopeComponents());
    assertEquals("localhost.jobmanager.name", group.getMetricIdentifier("name"));
    registry.shutdown().get();
}
Also used : MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) Test(org.junit.Test)

Example 25 with MetricRegistryImpl

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

the class MetricGroupRegistrationTest method testDuplicateGroupName.

/**
 * Verifies that when attempting to create a group with the name of an existing one the existing
 * one will be returned instead.
 */
@Test
public void testDuplicateGroupName() throws Exception {
    Configuration config = new Configuration();
    MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryTestUtils.fromConfiguration(config));
    MetricGroup root = TaskManagerMetricGroup.createTaskManagerMetricGroup(registry, "host", new ResourceID("id"));
    MetricGroup group1 = root.addGroup("group");
    MetricGroup group2 = root.addGroup("group");
    MetricGroup group3 = root.addGroup("group");
    Assert.assertTrue(group1 == group2 && group2 == group3);
    registry.shutdown().get();
}
Also used : Configuration(org.apache.flink.configuration.Configuration) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) MetricGroup(org.apache.flink.metrics.MetricGroup) MetricRegistryImpl(org.apache.flink.runtime.metrics.MetricRegistryImpl) 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