Java Code Examples for org.apache.nifi.controller.status.ConnectionStatus#setSourceId()
The following examples show how to use
org.apache.nifi.controller.status.ConnectionStatus#setSourceId() .
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: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
public static ConnectionStatus generateConnectionStatus(String id, String namePrefix) { ConnectionStatus cStatus = new ConnectionStatus(); cStatus.setId(id); cStatus.setName(namePrefix + "-" + UUID.randomUUID().toString()); cStatus.setBackPressureDataSizeThreshold("1 KB"); // sets backPressureBytesThreshold too cStatus.setBackPressureObjectThreshold(1l); cStatus.setInputBytes(2l); cStatus.setInputCount(3); cStatus.setMaxQueuedBytes(4l); cStatus.setMaxQueuedCount(5); cStatus.setOutputBytes(6); cStatus.setOutputCount(7); cStatus.setQueuedBytes(8l); cStatus.setQueuedCount(9); cStatus.setSourceId(id); cStatus.setSourceName("source"); cStatus.setDestinationId(id); cStatus.setDestinationName(null); return cStatus; }
Example 2
Source File: TestNiFiRemotePort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testRemoteOutputPortHTTP() { final String componentType = "Remote Output Port"; final String transitUri = "http://0.example.com:8080/nifi-api/data-transfer/output-ports/port-guid/transactions/tx-guid/flow-files"; final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); when(record.getComponentId()).thenReturn("port-guid"); when(record.getComponentType()).thenReturn(componentType); when(record.getTransitUri()).thenReturn(transitUri); when(record.getEventType()).thenReturn(ProvenanceEventType.RECEIVE); final NamespaceResolvers namespaceResolvers = Mockito.mock(NamespaceResolvers.class); when(namespaceResolvers.fromHostNames(matches(".+\\.example\\.com"))).thenReturn("namespace1"); final List<ConnectionStatus> connections = new ArrayList<>(); final ConnectionStatus connection = new ConnectionStatus(); connection.setSourceId("port-guid"); connection.setSourceName("outputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionFrom(matches("port-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, record.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, record); assertEquals(1, refs.getInputs().size()); assertEquals(0, refs.getOutputs().size()); Referenceable ref = refs.getInputs().iterator().next(); assertEquals(TYPE_NIFI_OUTPUT_PORT, ref.getTypeName()); assertEquals("outputPortA", ref.get(ATTR_NAME)); assertEquals("port-guid@namespace1", ref.get(ATTR_QUALIFIED_NAME)); }
Example 3
Source File: TestNiFiRemotePort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testRemoteOutputPortRAW() { final String componentType = "Remote Output Port"; // The UUID in a Transit Uri is a FlowFile UUID final String transitUri = "nifi://0.example.com:8081/232018cc-a147-40c6-b148-21f9f814e93c"; final ProvenanceEventRecord record = Mockito.mock(ProvenanceEventRecord.class); // Component Id is an UUID of the RemoteGroupPort instance acting as a S2S client. when(record.getComponentId()).thenReturn("s2s-client-component-guid"); when(record.getComponentType()).thenReturn(componentType); when(record.getTransitUri()).thenReturn(transitUri); when(record.getEventType()).thenReturn(ProvenanceEventType.RECEIVE); when(record.getAttribute(SiteToSiteAttributes.S2S_PORT_ID.key())).thenReturn("remote-port-guid"); final NamespaceResolvers namespaceResolvers = Mockito.mock(NamespaceResolvers.class); when(namespaceResolvers.fromHostNames(matches(".+\\.example\\.com"))).thenReturn("namespace1"); final List<ConnectionStatus> connections = new ArrayList<>(); final ConnectionStatus connection = new ConnectionStatus(); connection.setSourceId("s2s-client-component-guid"); connection.setSourceName("outputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionFrom(matches("s2s-client-component-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, record.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, record); assertEquals(1, refs.getInputs().size()); assertEquals(0, refs.getOutputs().size()); Referenceable ref = refs.getInputs().iterator().next(); assertEquals(TYPE_NIFI_OUTPUT_PORT, ref.getTypeName()); assertEquals("outputPortA", ref.get(ATTR_NAME)); assertEquals("remote-port-guid@namespace1", ref.get(ATTR_QUALIFIED_NAME)); }
Example 4
Source File: TestNiFiRootGroupPort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testInputPortHTTP() { final String componentType = "Input Port"; final String transitUri = "http://0.example.com:8080/nifi-api/data-transfer/input-ports/port-guid/transactions/tx-guid/flow-files"; final ProvenanceEventRecord receiveEvent = Mockito.mock(ProvenanceEventRecord.class); when(receiveEvent.getEventId()).thenReturn(123L); when(receiveEvent.getComponentId()).thenReturn("port-guid"); when(receiveEvent.getComponentType()).thenReturn(componentType); when(receiveEvent.getTransitUri()).thenReturn(transitUri); when(receiveEvent.getEventType()).thenReturn(ProvenanceEventType.RECEIVE); final NamespaceResolvers namespaceResolvers = Mockito.mock(NamespaceResolvers.class); when(namespaceResolvers.fromHostNames(matches(".+\\.example\\.com"))).thenReturn("namespace1"); final List<ConnectionStatus> connections = new ArrayList<>(); final ConnectionStatus connection = new ConnectionStatus(); connection.setSourceId("port-guid"); connection.setSourceName("inputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionFrom(matches("port-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, receiveEvent.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, receiveEvent); assertEquals(1, refs.getInputs().size()); assertEquals(0, refs.getOutputs().size()); assertEquals(1, refs.getComponentIds().size()); // Should report connected componentId. assertTrue(refs.getComponentIds().contains("port-guid")); Referenceable ref = refs.getInputs().iterator().next(); assertEquals(TYPE_NIFI_INPUT_PORT, ref.getTypeName()); assertEquals("inputPortA", ref.get(ATTR_NAME)); assertEquals("port-guid@namespace1", ref.get(ATTR_QUALIFIED_NAME)); }
Example 5
Source File: TestNiFiRootGroupPort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testRemoteInputPortRAW() { final String componentType = "Input Port"; // The UUID in a Transit Uri is a FlowFile UUID final String transitUri = "nifi://0.example.com:8081/580b7989-a80b-4089-b25b-3f5e0103af82"; final ProvenanceEventRecord receiveEvent = Mockito.mock(ProvenanceEventRecord.class); when(receiveEvent.getEventId()).thenReturn(123L); when(receiveEvent.getComponentId()).thenReturn("port-guid"); when(receiveEvent.getComponentType()).thenReturn(componentType); when(receiveEvent.getTransitUri()).thenReturn(transitUri); when(receiveEvent.getEventType()).thenReturn(ProvenanceEventType.RECEIVE); final NamespaceResolvers namespaceResolvers = Mockito.mock(NamespaceResolvers.class); when(namespaceResolvers.fromHostNames(matches(".+\\.example\\.com"))).thenReturn("namespace1"); final List<ConnectionStatus> connections = new ArrayList<>(); final ConnectionStatus connection = new ConnectionStatus(); connection.setSourceId("port-guid"); connection.setSourceName("inputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionFrom(matches("port-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, receiveEvent.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, receiveEvent); assertEquals(1, refs.getInputs().size()); assertEquals(0, refs.getOutputs().size()); assertEquals(1, refs.getComponentIds().size()); // Should report connected componentId. assertTrue(refs.getComponentIds().contains("port-guid")); Referenceable ref = refs.getInputs().iterator().next(); assertEquals(TYPE_NIFI_INPUT_PORT, ref.getTypeName()); assertEquals("inputPortA", ref.get(ATTR_NAME)); assertEquals("port-guid@namespace1", ref.get(ATTR_QUALIFIED_NAME)); }
Example 6
Source File: TestNiFiFlowAnalyzer.java From nifi with Apache License 2.0 | 5 votes |
private void connect(ProcessGroupStatus pg0, Tuple<String, String> comp0, Tuple<String, String> comp1) { ConnectionStatus conn = new ConnectionStatus(); conn.setId(nextComponentId()); conn.setGroupId(pg0.getId()); conn.setSourceId(comp0.getKey()); conn.setSourceName(comp0.getValue()); conn.setDestinationId(comp1.getKey()); conn.setDestinationName(comp1.getValue()); pg0.getConnectionStatus().add(conn); }