org.apache.flink.runtime.metrics.groups.MetricGroupTest Java Examples

The following examples show how to use org.apache.flink.runtime.metrics.groups.MetricGroupTest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetricRegistryImplTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testExceptionIsolation() throws Exception {
	MetricRegistryImpl registry = new MetricRegistryImpl(
		MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
		Arrays.asList(
			ReporterSetup.forReporter("test1", new FailingReporter()),
			ReporterSetup.forReporter("test2", new TestReporter7())));

	Counter metric = new SimpleCounter();
	registry.register(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));

	assertEquals(metric, TestReporter7.addedMetric);
	assertEquals("counter", TestReporter7.addedMetricName);

	registry.unregister(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));

	assertEquals(metric, TestReporter7.removedMetric);
	assertEquals("counter", TestReporter7.removedMetricName);

	registry.shutdown().get();
}
 
Example #2
Source File: MetricRegistryImplTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testExceptionIsolation() throws Exception {
	MetricRegistryImpl registry = new MetricRegistryImpl(
		MetricRegistryConfiguration.defaultMetricRegistryConfiguration(),
		Arrays.asList(
			ReporterSetup.forReporter("test1", new FailingReporter()),
			ReporterSetup.forReporter("test2", new TestReporter7())));

	Counter metric = new SimpleCounter();
	registry.register(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));

	assertEquals(metric, TestReporter7.addedMetric);
	assertEquals("counter", TestReporter7.addedMetricName);

	registry.unregister(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));

	assertEquals(metric, TestReporter7.removedMetric);
	assertEquals("counter", TestReporter7.removedMetricName);

	registry.shutdown().get();
}
 
Example #3
Source File: FlinkMetricContainerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegisterMetricGroup() {
	MetricKey key = MetricKey.create("step", MetricName.named(DEFAULT_NAMESPACE, "name"));

	MetricRegistry registry = NoOpMetricRegistry.INSTANCE;
	GenericMetricGroup root = new GenericMetricGroup(
		registry,
		new MetricGroupTest.DummyAbstractMetricGroup(registry),
		"root");
	MetricGroup metricGroup = FlinkMetricContainer.registerMetricGroup(key, root);

	assertThat(metricGroup.getScopeComponents(), is(Arrays.asList("root", "key", "value").toArray()));
}
 
Example #4
Source File: PythonTestUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
public static FlinkMetricContainer createMockFlinkMetricContainer() {
	return new FlinkMetricContainer(
		new GenericMetricGroup(
			NoOpMetricRegistry.INSTANCE,
			new MetricGroupTest.DummyAbstractMetricGroup(NoOpMetricRegistry.INSTANCE),
			"root"));
}
 
Example #5
Source File: MetricRegistryImplTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testExceptionIsolation() throws Exception {

	Configuration config = new Configuration();
	config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test1." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, FailingReporter.class.getName());
	config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test2." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter7.class.getName());

	MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(config));

	Counter metric = new SimpleCounter();
	registry.register(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));

	assertEquals(metric, TestReporter7.addedMetric);
	assertEquals("counter", TestReporter7.addedMetricName);

	registry.unregister(metric, "counter", new MetricGroupTest.DummyAbstractMetricGroup(registry));

	assertEquals(metric, TestReporter7.removedMetric);
	assertEquals("counter", TestReporter7.removedMetricName);

	registry.shutdown().get();
}