use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.
the class TaskMetricGroupTest method testCreateQueryServiceMetricInfo.
@Test
public void testCreateQueryServiceMetricInfo() {
JobID jid = new JobID();
AbstractID vid = new AbstractID();
AbstractID eid = new AbstractID();
MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, jid, "jobname");
TaskMetricGroup task = new TaskMetricGroup(registry, job, vid, eid, "taskName", 4, 5);
QueryScopeInfo.TaskQueryScopeInfo info = task.createQueryServiceMetricInfo(new DummyCharacterFilter());
assertEquals("", info.scope);
assertEquals(jid.toString(), info.jobID);
assertEquals(vid.toString(), info.vertexID);
assertEquals(4, info.subtaskIndex);
}
use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.
the class JobManagerGroupTest method testGenerateScopeDefault.
// ------------------------------------------------------------------------
// scope name tests
// ------------------------------------------------------------------------
@Test
public void testGenerateScopeDefault() {
MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
JobManagerMetricGroup group = new JobManagerMetricGroup(registry, "localhost");
assertArrayEquals(new String[] { "localhost", "jobmanager" }, group.getScopeComponents());
assertEquals("localhost.jobmanager.name", group.getMetricIdentifier("name"));
registry.shutdown();
}
use of org.apache.flink.runtime.metrics.MetricRegistry 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() {
Configuration config = new Configuration();
MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
MetricGroup root = new TaskManagerMetricGroup(registry, "host", "id");
MetricGroup group1 = root.addGroup("group");
MetricGroup group2 = root.addGroup("group");
MetricGroup group3 = root.addGroup("group");
Assert.assertTrue(group1 == group2 && group2 == group3);
registry.shutdown();
}
use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.
the class MetricGroupRegistrationTest method testMetricInstantiation.
/**
* Verifies that group methods instantiate the correct metric with the given name.
*/
@Test
public void testMetricInstantiation() {
Configuration config = new Configuration();
config.setString(ConfigConstants.METRICS_REPORTERS_LIST, "test");
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter1.class.getName());
MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
MetricGroup root = new TaskManagerMetricGroup(registry, "host", "id");
Counter counter = root.counter("counter");
assertEquals(counter, TestReporter1.lastPassedMetric);
assertEquals("counter", TestReporter1.lastPassedName);
Gauge<Object> gauge = root.gauge("gauge", new Gauge<Object>() {
@Override
public Object getValue() {
return null;
}
});
Assert.assertEquals(gauge, TestReporter1.lastPassedMetric);
assertEquals("gauge", TestReporter1.lastPassedName);
Histogram histogram = root.histogram("histogram", new Histogram() {
@Override
public void update(long value) {
}
@Override
public long getCount() {
return 0;
}
@Override
public HistogramStatistics getStatistics() {
return null;
}
});
Assert.assertEquals(histogram, TestReporter1.lastPassedMetric);
assertEquals("histogram", TestReporter1.lastPassedName);
registry.shutdown();
}
use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.
the class MetricGroupTest method testCreateQueryServiceMetricInfo.
@Test
public void testCreateQueryServiceMetricInfo() {
JobID jid = new JobID();
AbstractID vid = new AbstractID();
AbstractID eid = new AbstractID();
MetricRegistry registry = new MetricRegistry(defaultMetricRegistryConfiguration);
TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, jid, "jobname");
TaskMetricGroup task = new TaskMetricGroup(registry, job, vid, eid, "taskName", 4, 5);
GenericMetricGroup userGroup1 = new GenericMetricGroup(registry, task, "hello");
GenericMetricGroup userGroup2 = new GenericMetricGroup(registry, userGroup1, "world");
QueryScopeInfo.TaskQueryScopeInfo info1 = (QueryScopeInfo.TaskQueryScopeInfo) userGroup1.createQueryServiceMetricInfo(new DummyCharacterFilter());
assertEquals("hello", info1.scope);
assertEquals(jid.toString(), info1.jobID);
assertEquals(vid.toString(), info1.vertexID);
assertEquals(4, info1.subtaskIndex);
QueryScopeInfo.TaskQueryScopeInfo info2 = (QueryScopeInfo.TaskQueryScopeInfo) userGroup2.createQueryServiceMetricInfo(new DummyCharacterFilter());
assertEquals("hello.world", info2.scope);
assertEquals(jid.toString(), info2.jobID);
assertEquals(vid.toString(), info2.vertexID);
assertEquals(4, info2.subtaskIndex);
}
Aggregations