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();
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations