Java Code Examples for org.apache.nifi.controller.status.ConnectionStatus#setDestinationName()
The following examples show how to use
org.apache.nifi.controller.status.ConnectionStatus#setDestinationName() .
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: ITReportLineageToAtlas.java From nifi with Apache License 2.0 | 5 votes |
private void setConnectionName(ConnectionStatus c) { if (c.getSourceName() == null || c.getSourceName().isEmpty()) { c.setSourceName(componentNames.get(c.getSourceId())); } if (c.getDestinationName() == null || c.getDestinationName().isEmpty()) { c.setDestinationName(componentNames.get(c.getDestinationId())); } }
Example 3
Source File: TestNiFiRemotePort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testRemoteInputPortHTTP() { final String componentType = "Remote 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 sendEvent = Mockito.mock(ProvenanceEventRecord.class); when(sendEvent.getEventId()).thenReturn(123L); when(sendEvent.getComponentId()).thenReturn("port-guid"); when(sendEvent.getComponentType()).thenReturn(componentType); when(sendEvent.getTransitUri()).thenReturn(transitUri); when(sendEvent.getEventType()).thenReturn(ProvenanceEventType.SEND); 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.setDestinationId("port-guid"); connection.setDestinationName("inputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionTo(matches("port-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, sendEvent.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, sendEvent); assertEquals(0, refs.getInputs().size()); assertEquals(1, refs.getOutputs().size()); assertEquals(1, refs.getComponentIds().size()); // Should report connected componentId. assertTrue(refs.getComponentIds().contains("port-guid")); Referenceable ref = refs.getOutputs().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 4
Source File: TestNiFiRootGroupPort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testRemoteOutputPortHTTP() { final String componentType = "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 sendEvent = Mockito.mock(ProvenanceEventRecord.class); when(sendEvent.getComponentId()).thenReturn("port-guid"); when(sendEvent.getComponentType()).thenReturn(componentType); when(sendEvent.getTransitUri()).thenReturn(transitUri); when(sendEvent.getEventType()).thenReturn(ProvenanceEventType.SEND); 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.setDestinationId("port-guid"); connection.setDestinationName("outputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionTo(matches("port-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, sendEvent.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, sendEvent); assertEquals(0, refs.getInputs().size()); assertEquals(1, refs.getOutputs().size()); Referenceable ref = refs.getOutputs().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 5
Source File: TestNiFiRootGroupPort.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testRemoteOutputPortRAW() { final String componentType = "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 sendEvent = Mockito.mock(ProvenanceEventRecord.class); when(sendEvent.getComponentId()).thenReturn("port-guid"); when(sendEvent.getComponentType()).thenReturn(componentType); when(sendEvent.getTransitUri()).thenReturn(transitUri); when(sendEvent.getEventType()).thenReturn(ProvenanceEventType.SEND); 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.setDestinationId("port-guid"); connection.setDestinationName("outputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionTo(matches("port-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, sendEvent.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, sendEvent); assertEquals(0, refs.getInputs().size()); assertEquals(1, refs.getOutputs().size()); Referenceable ref = refs.getOutputs().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 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); }
Example 7
Source File: TestNiFiRemotePort.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testRemoteInputPortRAW() { final String componentType = "Remote 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 sendEvent = Mockito.mock(ProvenanceEventRecord.class); when(sendEvent.getEventId()).thenReturn(123L); // Component Id is an UUID of the RemoteGroupPort instance acting as a S2S client. when(sendEvent.getComponentId()).thenReturn("s2s-client-component-guid"); when(sendEvent.getComponentType()).thenReturn(componentType); when(sendEvent.getTransitUri()).thenReturn(transitUri); when(sendEvent.getEventType()).thenReturn(ProvenanceEventType.SEND); when(sendEvent.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.setDestinationId("s2s-client-component-guid"); connection.setDestinationName("inputPortA"); connections.add(connection); final AnalysisContext context = Mockito.mock(AnalysisContext.class); when(context.getNamespaceResolver()).thenReturn(namespaceResolvers); when(context.findConnectionTo(matches("s2s-client-component-guid"))).thenReturn(connections); final NiFiProvenanceEventAnalyzer analyzer = NiFiProvenanceEventAnalyzerFactory.getAnalyzer(componentType, transitUri, sendEvent.getEventType()); assertNotNull(analyzer); final DataSetRefs refs = analyzer.analyze(context, sendEvent); assertEquals(0, refs.getInputs().size()); assertEquals(1, refs.getOutputs().size()); assertEquals(1, refs.getComponentIds().size()); // Should report connected componentId. assertTrue(refs.getComponentIds().contains("s2s-client-component-guid")); Referenceable ref = refs.getOutputs().iterator().next(); assertEquals(TYPE_NIFI_INPUT_PORT, ref.getTypeName()); assertEquals("inputPortA", ref.get(ATTR_NAME)); assertEquals("remote-port-guid@namespace1", ref.get(ATTR_QUALIFIED_NAME)); }