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