org.apache.flink.runtime.metrics.groups.GenericMetricGroup Java Examples
The following examples show how to use
org.apache.flink.runtime.metrics.groups.GenericMetricGroup.
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: LatencyStatsTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static void testLatencyStats( final LatencyStats.Granularity granularity, final Consumer<List<Tuple2<String, Histogram>>> verifier) { final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup(); final TestMetricRegistry registry = new TestMetricRegistry(); final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME); final LatencyStats latencyStats = new LatencyStats( parentGroup, MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(), OPERATOR_SUBTASK_INDEX, OPERATOR_ID, granularity); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3)); verifier.accept(registry.latencyHistograms); }
Example #2
Source File: LatencyStatsTest.java From flink with Apache License 2.0 | 6 votes |
private static void testLatencyStats( final LatencyStats.Granularity granularity, final Consumer<List<Tuple2<String, Histogram>>> verifier) { final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup(); final TestMetricRegistry registry = new TestMetricRegistry(); final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME); final LatencyStats latencyStats = new LatencyStats( parentGroup, MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(), OPERATOR_SUBTASK_INDEX, OPERATOR_ID, granularity); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3)); verifier.accept(registry.latencyHistograms); }
Example #3
Source File: LatencyStatsTest.java From flink with Apache License 2.0 | 6 votes |
private static void testLatencyStats( final LatencyStats.Granularity granularity, final Consumer<List<Tuple2<String, Histogram>>> verifier) { final AbstractMetricGroup<?> dummyGroup = UnregisteredMetricGroups.createUnregisteredOperatorMetricGroup(); final TestMetricRegistry registry = new TestMetricRegistry(); final MetricGroup parentGroup = new GenericMetricGroup(registry, dummyGroup, PARENT_GROUP_NAME); final LatencyStats latencyStats = new LatencyStats( parentGroup, MetricOptions.LATENCY_HISTORY_SIZE.defaultValue(), OPERATOR_SUBTASK_INDEX, OPERATOR_ID, granularity); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 0)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_1, 1)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 2)); latencyStats.reportLatency(new LatencyMarker(0L, SOURCE_ID_2, 3)); verifier.accept(registry.latencyHistograms); }
Example #4
Source File: RocksDBNativeMetricMonitorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testReturnsUnsigned() throws Throwable { RocksDBResource localRocksDBResource = new RocksDBResource(); localRocksDBResource.before(); SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, localRocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = rocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.setValue(-1); BigInteger result = view.getValue(); localRocksDBResource.after(); Assert.assertEquals("Failed to interpret RocksDB result as an unsigned long", 1, result.signum()); }
Example #5
Source File: RocksDBNativeMetricMonitorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testClosedGaugesDontRead() { SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, rocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = rocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.close(); view.update(); Assert.assertEquals("Closed gauge still queried RocksDB", BigInteger.ZERO, view.getValue()); }
Example #6
Source File: RocksDBNativeMetricMonitorTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testReturnsUnsigned() throws Throwable { RocksDBResource localRocksDBResource = new RocksDBResource(); localRocksDBResource.before(); SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, localRocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = rocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.setValue(-1); BigInteger result = view.getValue(); localRocksDBResource.after(); Assert.assertEquals("Failed to interpret RocksDB result as an unsigned long", 1, result.signum()); }
Example #7
Source File: RocksDBNativeMetricMonitorTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testClosedGaugesDontRead() { SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, rocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = rocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.close(); view.update(); Assert.assertEquals("Closed gauge still queried RocksDB", BigInteger.ZERO, view.getValue()); }
Example #8
Source File: FlinkMetricContainerTest.java From flink with Apache License 2.0 | 5 votes |
@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 #9
Source File: PythonTestUtils.java From flink with Apache License 2.0 | 5 votes |
public static FlinkMetricContainer createMockFlinkMetricContainer() { return new FlinkMetricContainer( new GenericMetricGroup( NoOpMetricRegistry.INSTANCE, new MetricGroupTest.DummyAbstractMetricGroup(NoOpMetricRegistry.INSTANCE), "root")); }
Example #10
Source File: RocksDBNativeMetricMonitorTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testReturnsUnsigned() throws Throwable { RocksDBResource localRocksDBResource = new RocksDBResource(); localRocksDBResource.before(); SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, localRocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = rocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.setValue(-1); BigInteger result = view.getValue(); localRocksDBResource.after(); Assert.assertEquals("Failed to interpret RocksDB result as an unsigned long", 1, result.signum()); }
Example #11
Source File: RocksDBNativeMetricMonitorTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testClosedGaugesDontRead() { SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, rocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = rocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.close(); view.update(); Assert.assertEquals("Closed gauge still queried RocksDB", BigInteger.ZERO, view.getValue()); }
Example #12
Source File: RocksDBNativeMetricMonitorTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testMetricMonitorLifecycle() throws Throwable { //We use a local variable here to manually control the life-cycle. // This allows us to verify that metrics do not try to access // RocksDB after the monitor was closed. RocksDBResource localRocksDBResource = new RocksDBResource(); localRocksDBResource.before(); SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); // always returns a non-zero // value since empty memtables // have overhead. options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, localRocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = localRocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); Assert.assertEquals("Failed to register metrics for column family", 1, registry.metrics.size()); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.update(); Assert.assertNotEquals("Failed to pull metric from RocksDB", BigInteger.ZERO, view.getValue()); view.setValue(0L); //After the monitor is closed no metric should be accessing RocksDB anymore. //If they do, then this test will likely fail with a segmentation fault. monitor.close(); localRocksDBResource.after(); view.update(); Assert.assertEquals("Failed to release RocksDB reference", BigInteger.ZERO, view.getValue()); }
Example #13
Source File: RocksDBNativeMetricMonitorTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testMetricMonitorLifecycle() throws Throwable { //We use a local variable here to manually control the life-cycle. // This allows us to verify that metrics do not try to access // RocksDB after the monitor was closed. RocksDBResource localRocksDBResource = new RocksDBResource(); localRocksDBResource.before(); SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); // always returns a non-zero // value since empty memtables // have overhead. options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, localRocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = localRocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); Assert.assertEquals("Failed to register metrics for column family", 1, registry.metrics.size()); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.update(); Assert.assertNotEquals("Failed to pull metric from RocksDB", BigInteger.ZERO, view.getValue()); view.setValue(0L); //After the monitor is closed no metric should be accessing RocksDB anymore. //If they do, then this test will likely fail with a segmentation fault. monitor.close(); localRocksDBResource.after(); view.update(); Assert.assertEquals("Failed to release RocksDB reference", BigInteger.ZERO, view.getValue()); }
Example #14
Source File: RocksDBNativeMetricMonitorTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testMetricMonitorLifecycle() throws Throwable { //We use a local variable here to manually control the life-cycle. // This allows us to verify that metrics do not try to access // RocksDB after the monitor was closed. RocksDBResource localRocksDBResource = new RocksDBResource(); localRocksDBResource.before(); SimpleMetricRegistry registry = new SimpleMetricRegistry(); GenericMetricGroup group = new GenericMetricGroup( registry, UnregisteredMetricGroups.createUnregisteredTaskMetricGroup(), OPERATOR_NAME ); RocksDBNativeMetricOptions options = new RocksDBNativeMetricOptions(); // always returns a non-zero // value since empty memtables // have overhead. options.enableSizeAllMemTables(); RocksDBNativeMetricMonitor monitor = new RocksDBNativeMetricMonitor( options, group, localRocksDBResource.getRocksDB() ); ColumnFamilyHandle handle = localRocksDBResource.createNewColumnFamily(COLUMN_FAMILY_NAME); monitor.registerColumnFamily(COLUMN_FAMILY_NAME, handle); Assert.assertEquals("Failed to register metrics for column family", 1, registry.metrics.size()); RocksDBNativeMetricMonitor.RocksDBNativeMetricView view = registry.metrics.get(0); view.update(); Assert.assertNotEquals("Failed to pull metric from RocksDB", BigInteger.ZERO, view.getValue()); view.setValue(0L); //After the monitor is closed no metric should be accessing RocksDB anymore. //If they do, then this test will likely fail with a segmentation fault. monitor.close(); localRocksDBResource.after(); view.update(); Assert.assertEquals("Failed to release RocksDB reference", BigInteger.ZERO, view.getValue()); }