Java Code Examples for org.apache.flink.runtime.metrics.NoOpMetricRegistry#INSTANCE
The following examples show how to use
org.apache.flink.runtime.metrics.NoOpMetricRegistry#INSTANCE .
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: MetricGroupTest.java From flink with Apache License 2.0 | 6 votes |
/** * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key name already * exists goes through the generic code path. */ @Test public void testNameCollisionForKeyAfterGenericGroup() { MetricRegistry registry = NoOpMetricRegistry.INSTANCE; GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root"); String key = "key"; String value = "value"; root.addGroup(key); MetricGroup group = root.addGroup(key, value); String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key")); assertNull(variableValue); String identifier = group.getMetricIdentifier("metric"); assertTrue("Key is missing from metric identifier.", identifier.contains("key")); assertTrue("Value is missing from metric identifier.", identifier.contains("value")); String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter()); assertTrue("Key is missing from logical scope.", logicalScope.contains(key)); assertTrue("Value is missing from logical scope.", logicalScope.contains(value)); }
Example 2
Source File: MetricGroupTest.java From flink with Apache License 2.0 | 6 votes |
/** * Verifies that existing key/value groups are returned when calling {@link MetricGroup#addGroup(String)}. */ @Test public void testNameCollisionAfterKeyValueGroup() { MetricRegistry registry = NoOpMetricRegistry.INSTANCE; GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root"); String key = "key"; String value = "value"; root.addGroup(key, value); MetricGroup group = root.addGroup(key).addGroup(value); String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key")); assertEquals(value, variableValue); String identifier = group.getMetricIdentifier("metric"); assertTrue("Key is missing from metric identifier.", identifier.contains("key")); assertTrue("Value is missing from metric identifier.", identifier.contains("value")); String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter()); assertTrue("Key is missing from logical scope.", logicalScope.contains(key)); assertFalse("Value is present in logical scope.", logicalScope.contains(value)); }
Example 3
Source File: MetricGroupTest.java From flink with Apache License 2.0 | 6 votes |
/** * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key and value name * already exists goes through the generic code path. */ @Test public void testNameCollisionForKeyAndValueAfterGenericGroup() { MetricRegistry registry = NoOpMetricRegistry.INSTANCE; GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root"); String key = "key"; String value = "value"; root.addGroup(key).addGroup(value); MetricGroup group = root.addGroup(key, value); String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key")); assertNull(variableValue); String identifier = group.getMetricIdentifier("metric"); assertTrue("Key is missing from metric identifier.", identifier.contains("key")); assertTrue("Value is missing from metric identifier.", identifier.contains("value")); String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter()); assertTrue("Key is missing from logical scope.", logicalScope.contains(key)); assertTrue("Value is missing from logical scope.", logicalScope.contains(value)); }
Example 4
Source File: MetricGroupTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Verifies that calling {@link MetricGroup#addGroup(String, String)} if a generic group with the key name already * exists goes through the generic code path. */ @Test public void testNameCollisionForKeyAfterGenericGroup() { MetricRegistry registry = NoOpMetricRegistry.INSTANCE; GenericMetricGroup root = new GenericMetricGroup(registry, new DummyAbstractMetricGroup(registry), "root"); String key = "key"; String value = "value"; root.addGroup(key); MetricGroup group = root.addGroup(key, value); String variableValue = group.getAllVariables().get(ScopeFormat.asVariable("key")); assertNull(variableValue); String identifier = group.getMetricIdentifier("metric"); assertTrue("Key is missing from metric identifier.", identifier.contains("key")); assertTrue("Value is missing from metric identifier.", identifier.contains("value")); String logicalScope = ((AbstractMetricGroup) group).getLogicalScope(new DummyCharacterFilter()); assertTrue("Key is missing from logical scope.", logicalScope.contains(key)); assertTrue("Value is missing from logical scope.", logicalScope.contains(value)); }
Example 5
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 6
Source File: ResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
private TestingResourceManager createAndStartResourceManager(HeartbeatServices heartbeatServices) throws Exception { final SlotManager slotManager = SlotManagerBuilder.newBuilder() .setScheduledExecutor(rpcService.getScheduledExecutor()) .build(); final JobLeaderIdService jobLeaderIdService = new JobLeaderIdService( highAvailabilityServices, rpcService.getScheduledExecutor(), TestingUtils.infiniteTime()); final TestingResourceManager resourceManager = new TestingResourceManager( rpcService, ResourceManager.RESOURCE_MANAGER_NAME + UUID.randomUUID(), resourceManagerResourceId, highAvailabilityServices, heartbeatServices, slotManager, NoOpMetricRegistry.INSTANCE, jobLeaderIdService, testingFatalErrorHandler, UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup()); resourceManager.start(); // first make the ResourceManager the leader resourceManagerId = ResourceManagerId.generate(); resourceManagerLeaderElectionService.isLeader(resourceManagerId.toUUID()).get(); return resourceManager; }
Example 7
Source File: AbstractMetricGroupTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testGetAllVariablesWithExclusions() { MetricRegistry registry = NoOpMetricRegistry.INSTANCE; AbstractMetricGroup<?> group = new ProcessMetricGroup(registry, "host"); assertEquals(group.getAllVariables(-1, Collections.singleton(ScopeFormat.SCOPE_HOST)).size(), 0); }
Example 8
Source File: ResourceManagerTaskExecutorTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private StandaloneResourceManager createAndStartResourceManager(LeaderElectionService rmLeaderElectionService, FatalErrorHandler fatalErrorHandler) throws Exception { TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices(); HeartbeatServices heartbeatServices = new HeartbeatServices(1000L, HEARTBEAT_TIMEOUT); highAvailabilityServices.setResourceManagerLeaderElectionService(rmLeaderElectionService); SlotManager slotManager = SlotManagerBuilder.newBuilder() .setScheduledExecutor(rpcService.getScheduledExecutor()) .build(); JobLeaderIdService jobLeaderIdService = new JobLeaderIdService( highAvailabilityServices, rpcService.getScheduledExecutor(), Time.minutes(5L)); StandaloneResourceManager resourceManager = new StandaloneResourceManager( rpcService, ResourceManager.RESOURCE_MANAGER_NAME + UUID.randomUUID(), resourceManagerResourceID, highAvailabilityServices, heartbeatServices, slotManager, NoOpMetricRegistry.INSTANCE, jobLeaderIdService, new ClusterInformation("localhost", 1234), fatalErrorHandler, UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup()); resourceManager.start(); return resourceManager; }
Example 9
Source File: ResourceManagerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private TestingResourceManager createAndStartResourceManager(HeartbeatServices heartbeatServices) throws Exception { final SlotManager slotManager = SlotManagerBuilder.newBuilder() .setScheduledExecutor(rpcService.getScheduledExecutor()) .build(); final JobLeaderIdService jobLeaderIdService = new JobLeaderIdService( highAvailabilityServices, rpcService.getScheduledExecutor(), TestingUtils.infiniteTime()); final TestingResourceManager resourceManager = new TestingResourceManager( rpcService, ResourceManager.RESOURCE_MANAGER_NAME + UUID.randomUUID(), resourceManagerResourceId, highAvailabilityServices, heartbeatServices, slotManager, NoOpMetricRegistry.INSTANCE, jobLeaderIdService, testingFatalErrorHandler, UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup()); resourceManager.start(); // first make the ResourceManager the leader resourceManagerId = ResourceManagerId.generate(); resourceManagerLeaderElectionService.isLeader(resourceManagerId.toUUID()).get(); return resourceManager; }
Example 10
Source File: UnregisteredMetricGroups.java From flink with Apache License 2.0 | 4 votes |
protected UnregisteredTaskManagerMetricGroup() { super(NoOpMetricRegistry.INSTANCE, DEFAULT_HOST_NAME, DEFAULT_TASKMANAGER_ID); }
Example 11
Source File: UnregisteredMetricGroups.java From flink with Apache License 2.0 | 4 votes |
protected UnregisteredJobManagerJobMetricGroup() { super(NoOpMetricRegistry.INSTANCE, new UnregisteredJobManagerMetricGroup(), DEFAULT_JOB_ID, DEFAULT_JOB_NAME); }
Example 12
Source File: TwoInputStreamTaskTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testOperatorMetricReuse() throws Exception { final TwoInputStreamTaskTestHarness<String, String, String> testHarness = new TwoInputStreamTaskTestHarness<>( TwoInputStreamTask::new, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO); testHarness.setupOperatorChain(new OperatorID(), new DuplicatingOperator()) .chain(new OperatorID(), new OneInputStreamTaskTest.DuplicatingOperator(), BasicTypeInfo.STRING_TYPE_INFO.createSerializer(new ExecutionConfig())) .chain(new OperatorID(), new OneInputStreamTaskTest.DuplicatingOperator(), BasicTypeInfo.STRING_TYPE_INFO.createSerializer(new ExecutionConfig())) .finish(); final TaskMetricGroup taskMetricGroup = new UnregisteredMetricGroups.UnregisteredTaskMetricGroup() { @Override public OperatorMetricGroup getOrAddOperator(OperatorID operatorID, String name) { return new OperatorMetricGroup(NoOpMetricRegistry.INSTANCE, this, operatorID, name); } }; final StreamMockEnvironment env = new StreamMockEnvironment( testHarness.jobConfig, testHarness.taskConfig, testHarness.memorySize, new MockInputSplitProvider(), testHarness.bufferSize, new TestTaskStateManager()) { @Override public TaskMetricGroup getMetricGroup() { return taskMetricGroup; } }; final Counter numRecordsInCounter = taskMetricGroup.getIOMetricGroup().getNumRecordsInCounter(); final Counter numRecordsOutCounter = taskMetricGroup.getIOMetricGroup().getNumRecordsOutCounter(); testHarness.invoke(env); testHarness.waitForTaskRunning(); final int numRecords1 = 5; final int numRecords2 = 3; for (int x = 0; x < numRecords1; x++) { testHarness.processElement(new StreamRecord<>("hello"), 0, 0); } for (int x = 0; x < numRecords2; x++) { testHarness.processElement(new StreamRecord<>("hello"), 1, 0); } testHarness.waitForInputProcessing(); assertEquals(numRecords1 + numRecords2, numRecordsInCounter.getCount()); assertEquals((numRecords1 + numRecords2) * 2 * 2 * 2, numRecordsOutCounter.getCount()); testHarness.endInput(); testHarness.waitForTaskCompletion(); }
Example 13
Source File: UnregisteredMetricGroups.java From flink with Apache License 2.0 | 4 votes |
protected UnregisteredTaskMetricGroup() { super(NoOpMetricRegistry.INSTANCE, new UnregisteredTaskManagerJobMetricGroup(), DEFAULT_VERTEX_ID, DEFAULT_ATTEMPT_ID, DEFAULT_TASK_NAME, 0, 0); }
Example 14
Source File: UnregisteredMetricGroups.java From flink with Apache License 2.0 | 4 votes |
UnregisteredSlotManagerMetricGroup() { super(NoOpMetricRegistry.INSTANCE, UNREGISTERED_HOST); }
Example 15
Source File: UnregisteredMetricGroups.java From flink with Apache License 2.0 | 4 votes |
public UnregisteredProcessMetricGroup() { super(NoOpMetricRegistry.INSTANCE, UNREGISTERED_HOST); }
Example 16
Source File: OneInputStreamTaskTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testOperatorMetricReuse() throws Exception { final OneInputStreamTaskTestHarness<String, String> testHarness = new OneInputStreamTaskTestHarness<>(OneInputStreamTask::new, BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.STRING_TYPE_INFO); testHarness.setupOperatorChain(new OperatorID(), new DuplicatingOperator()) .chain(new OperatorID(), new DuplicatingOperator(), BasicTypeInfo.STRING_TYPE_INFO.createSerializer(new ExecutionConfig())) .chain(new OperatorID(), new DuplicatingOperator(), BasicTypeInfo.STRING_TYPE_INFO.createSerializer(new ExecutionConfig())) .finish(); final TaskMetricGroup taskMetricGroup = new UnregisteredMetricGroups.UnregisteredTaskMetricGroup() { @Override public OperatorMetricGroup getOrAddOperator(OperatorID operatorID, String name) { return new OperatorMetricGroup(NoOpMetricRegistry.INSTANCE, this, operatorID, name); } }; final StreamMockEnvironment env = new StreamMockEnvironment( testHarness.jobConfig, testHarness.taskConfig, testHarness.memorySize, new MockInputSplitProvider(), testHarness.bufferSize, new TestTaskStateManager()) { @Override public TaskMetricGroup getMetricGroup() { return taskMetricGroup; } }; final Counter numRecordsInCounter = taskMetricGroup.getIOMetricGroup().getNumRecordsInCounter(); final Counter numRecordsOutCounter = taskMetricGroup.getIOMetricGroup().getNumRecordsOutCounter(); testHarness.invoke(env); testHarness.waitForTaskRunning(); final int numRecords = 5; for (int x = 0; x < numRecords; x++) { testHarness.processElement(new StreamRecord<>("hello")); } testHarness.waitForInputProcessing(); assertEquals(numRecords, numRecordsInCounter.getCount()); assertEquals(numRecords * 2 * 2 * 2, numRecordsOutCounter.getCount()); testHarness.endInput(); testHarness.waitForTaskCompletion(); }
Example 17
Source File: UnregisteredMetricGroups.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
protected UnregisteredTaskManagerJobMetricGroup() { super(NoOpMetricRegistry.INSTANCE, new UnregisteredTaskManagerMetricGroup(), DEFAULT_JOB_ID, DEFAULT_JOB_NAME); }
Example 18
Source File: UnregisteredMetricGroups.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
protected UnregisteredTaskManagerMetricGroup() { super(NoOpMetricRegistry.INSTANCE, DEFAULT_HOST_NAME, DEFAULT_TASKMANAGER_ID); }
Example 19
Source File: UnregisteredMetricGroups.java From flink with Apache License 2.0 | 4 votes |
protected UnregisteredTaskManagerJobMetricGroup() { super(NoOpMetricRegistry.INSTANCE, new UnregisteredTaskManagerMetricGroup(), DEFAULT_JOB_ID, DEFAULT_JOB_NAME); }
Example 20
Source File: UnregisteredMetricGroups.java From flink with Apache License 2.0 | 4 votes |
protected UnregisteredTaskMetricGroup() { super(NoOpMetricRegistry.INSTANCE, new UnregisteredTaskManagerJobMetricGroup(), DEFAULT_VERTEX_ID, DEFAULT_ATTEMPT_ID, DEFAULT_TASK_NAME, 0, 0); }