You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "kevdoran (via GitHub)" <gi...@apache.org> on 2026/02/09 15:42:45 UTC
[PR] NIFI-15355 Connector Configuration Repository [nifi]
kevdoran opened a new pull request, #10876:
URL: https://github.com/apache/nifi/pull/10876
<!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
<!-- contributor license agreements. See the NOTICE file distributed with -->
<!-- this work for additional information regarding copyright ownership. -->
<!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
<!-- (the "License"); you may not use this file except in compliance with -->
<!-- the License. You may obtain a copy of the License at -->
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- Unless required by applicable law or agreed to in writing, software -->
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->
# Summary
[NIFI-15255](https://issues.apache.org/jira/browse/NIFI-15255)
## Motivation
Connector working configuration currently lives only in memory and is persisted to `flow.json.gz`. There is no way for an external system to manage or override it. This PR introduces `ConnectorConfigurationProvider`, a framework extension point that allows Connector name and working flow configuration to be persisted in and loaded from an external store.
## Architecture
`ConnectorConfigurationProvider` is a nullable collaborator of `StandardConnectorRepository`. When absent (the default), all behavior is unchanged. When present, the repository calls it on every read and write:
```mermaid
graph TB
subgraph "REST / Service / DAO Layers"
CR["ConnectorResource"]
SF["NiFiServiceFacade"]
DAO["ConnectorDAO"]
end
subgraph "Controller Layer"
FC["FlowController"]
FM["FlowManager"]
end
subgraph "Repository Layer"
REPO["ConnectorRepository (StandardConnectorRepository)"]
ASSETREPO["ConnectorAssetRepository"]
CCP["🆕 ConnectorConfigurationProvider (nullable, NAR-discovered)"]
end
subgraph "In-Memory"
CN["ConnectorNode"]
AFC["activeFlowContext"]
WFC["workingFlowContext"]
end
subgraph "Persistence"
FLOW["flow.json.gz"]
EXT["🆕 External Store (database, etc.)"]
end
CR --> SF --> DAO --> REPO
DAO --> FM --> CN
REPO --> CN
REPO --> ASSETREPO
REPO -->|"load / save / discard / delete / verifyCreate"| CCP
CCP --> EXT
CN --> AFC
CN --> WFC
SF -.->|"saveFlow()"| FLOW
```
**Read operations** (`getConnector`, `getConnectors`, `addConnector`, `applyUpdate`) call `provider.load()` and override the in-memory name and working flow configuration with the provider's values.
**Write operations** (`configureConnector`, `discardWorkingConfiguration`, `updateConnector`) sync with the provider *before* modifying in-memory state. If the provider throws, the `ConnectorNode` is unchanged.
**Cluster sync** (`inheritConfiguration`) does *not* interact with the provider, as the design is that cluster operations such as a new node joining the cluster should always inherit the current, local connector state.
Provider failures propagate as `ConnectorConfigurationProviderException` rather than being silently swallowed, giving implementations control over failure semantics.
## New Types (`nifi-framework-api`)
- **`ConnectorConfigurationProvider`** -- Extension point interface: `initialize`, `load`, `save`, `discard`, `delete`, `verifyCreate`
- **`ConnectorConfigurationProviderInitializationContext`** -- Exposes `Map<String, String>` properties (following the established NiFi initialization context pattern)
- **`ConnectorWorkingConfiguration`** -- Mutable POJO carrying `name` and `List<VersionedConfigurationStep> workingFlowConfiguration`
- **`ConnectorConfigurationProviderException`** -- RuntimeException for provider failures
## Other Changes
- **Centralized `ConnectorNode` metadata updates** -- All name modifications now go through `ConnectorRepository.updateConnector()` instead of calling `connectorNode.setName()` directly. Updated call sites: `StandardNiFiServiceFacade` (via new `ConnectorDAO.updateConnector()`), `VersionedFlowSynchronizer`.
- **Centralized create verification** -- `ConnectorRepository.verifyCreate()` checks for duplicate IDs and delegates to `provider.verifyCreate()`. `StandardConnectorDAO.verifyCreate()` now delegates to the repository.
- **Removed redundant `addConnector()`** -- `StandardConnectorDAO.createConnector()` no longer calls `addConnector()` since `FlowManager.createConnector()` already does this.
## Configuration
```properties
nifi.components.connectors.configuration.provider.implementation=com.example.MyProvider
nifi.components.connectors.configuration.provider.db.url=jdbc:postgresql://localhost/nifi
```
## Testing
25 unit tests in `TestStandardConnectorRepository` covering read overrides, write-through atomicity, partial merge semantics, lifecycle delegation, exception propagation, cluster sync exclusion, and `verifyCreate` / `addConnector` atomicity. Updated `StandardConnectorDAOTest` for `verifyCreate` delegation.
## Files Changed
17 files, +975 / -30. Four new types in `nifi-framework-api`, one new implementation in `nifi-framework-core`, twelve modified files across `nifi-framework-core`, `nifi-framework-core-api`, `nifi-web-api`, and `nifi-properties`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15355 Connector Configuration Repository [nifi]
Posted by "bbende (via GitHub)" <gi...@apache.org>.
bbende commented on code in PR #10876:
URL: https://github.com/apache/nifi/pull/10876#discussion_r2783568524
##########
nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java:
##########
@@ -142,6 +142,10 @@ public class NiFiProperties extends ApplicationProperties {
// Connector Repository properties
public static final String CONNECTOR_REPOSITORY_IMPLEMENTATION = "nifi.components.connectors.repository.implementation";
+ // Connector Configuration Provider properties
+ public static final String CONNECTOR_CONFIGURATION_PROVIDER_IMPLEMENTATION = "nifi.components.connectors.configuration.provider.implementation";
+ public static final String CONNECTOR_CONFIGURATION_PROVIDER_PROPERTIES_PREFIX = "nifi.components.connectors.configuration.provider.";
Review Comment:
Minor - would consider updating the default `nifi.properties` to include these
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15355 Connector Configuration Repository [nifi]
Posted by "kevdoran (via GitHub)" <gi...@apache.org>.
kevdoran commented on code in PR #10876:
URL: https://github.com/apache/nifi/pull/10876#discussion_r2783626407
##########
nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java:
##########
@@ -142,6 +142,10 @@ public class NiFiProperties extends ApplicationProperties {
// Connector Repository properties
public static final String CONNECTOR_REPOSITORY_IMPLEMENTATION = "nifi.components.connectors.repository.implementation";
+ // Connector Configuration Provider properties
+ public static final String CONNECTOR_CONFIGURATION_PROVIDER_IMPLEMENTATION = "nifi.components.connectors.configuration.provider.implementation";
+ public static final String CONNECTOR_CONFIGURATION_PROVIDER_PROPERTIES_PREFIX = "nifi.components.connectors.configuration.provider.";
Review Comment:
I added it. I left it blank by default (with a mvn/env override) because there is no standard implementation by default, it is a nullable/optional collaborator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15355 Connector Configuration Repository [nifi]
Posted by "kevdoran (via GitHub)" <gi...@apache.org>.
kevdoran commented on PR #10876:
URL: https://github.com/apache/nifi/pull/10876#issuecomment-3873782054
Thanks all. I've addressed the feedback and pushed updates to the PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15355 Connector Configuration Repository [nifi]
Posted by "sfc-gh-mpayne (via GitHub)" <gi...@apache.org>.
sfc-gh-mpayne commented on code in PR #10876:
URL: https://github.com/apache/nifi/pull/10876#discussion_r2784190888
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/connector/TestStandardConnectorRepository.java:
##########
@@ -191,4 +204,393 @@ public void testDiscardWorkingConfigurationPreservesWorkingAssets() {
verify(assetManager, never()).deleteAsset(workingAssetId);
verify(assetManager).deleteAsset(unreferencedAssetId);
}
+
+ @Test
+ public void testGetConnectorWithProviderOverridesWorkingConfig() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final MutableConnectorConfigurationContext workingConfigContext = mock(MutableConnectorConfigurationContext.class);
+ final ConnectorNode connector = createConnectorNodeWithWorkingConfig("connector-1", "Original Name", workingConfigContext);
+ repository.addConnector(connector);
+
+ final ConnectorWorkingConfiguration externalConfig = new ConnectorWorkingConfiguration();
+ externalConfig.setName("External Name");
+ final VersionedConfigurationStep externalStep = createVersionedStep("step1", Map.of("prop1", createStringLiteralRef("external-value")));
+ externalConfig.setWorkingFlowConfiguration(List.of(externalStep));
+ when(provider.load("connector-1")).thenReturn(Optional.of(externalConfig));
+
+ final ConnectorNode result = repository.getConnector("connector-1");
+
+ assertNotNull(result);
+ verify(connector).setName("External Name");
+ verify(workingConfigContext).replaceProperties(eq("step1"), any(StepConfiguration.class));
+ }
+
+ @Test
+ public void testGetConnectorWithProviderReturnsEmpty() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createSimpleConnectorNode("connector-1", "Original Name");
+ repository.addConnector(connector);
+
+ when(provider.load("connector-1")).thenReturn(Optional.empty());
+
+ final ConnectorNode result = repository.getConnector("connector-1");
+
+ assertNotNull(result);
+ verify(connector, never()).setName(anyString());
+ }
+
+ @Test
+ public void testGetConnectorWithProviderThrowsException() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createSimpleConnectorNode("connector-1", "Original Name");
+ repository.addConnector(connector);
+
+ when(provider.load("connector-1")).thenThrow(new ConnectorConfigurationProviderException("Provider failure"));
+
+ assertThrows(ConnectorConfigurationProviderException.class, () -> repository.getConnector("connector-1"));
+ verify(connector, never()).setName(anyString());
+ }
+
+ @Test
+ public void testGetConnectorWithNullProvider() {
+ final StandardConnectorRepository repository = createRepositoryWithProvider(null);
+
+ final ConnectorNode connector = createSimpleConnectorNode("connector-1", "Original Name");
+ repository.addConnector(connector);
+
+ final ConnectorNode result = repository.getConnector("connector-1");
+
+ assertNotNull(result);
+ verify(connector, never()).setName(anyString());
+ }
+
+ @Test
+ public void testGetConnectorsWithProviderOverrides() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final MutableConnectorConfigurationContext workingConfig1 = mock(MutableConnectorConfigurationContext.class);
+ final MutableConnectorConfigurationContext workingConfig2 = mock(MutableConnectorConfigurationContext.class);
+ final ConnectorNode connector1 = createConnectorNodeWithWorkingConfig("connector-1", "Name 1", workingConfig1);
+ final ConnectorNode connector2 = createConnectorNodeWithWorkingConfig("connector-2", "Name 2", workingConfig2);
+ repository.addConnector(connector1);
+ repository.addConnector(connector2);
+
+ final ConnectorWorkingConfiguration externalConfig1 = new ConnectorWorkingConfiguration();
+ externalConfig1.setName("External Name 1");
+ externalConfig1.setWorkingFlowConfiguration(List.of());
+ when(provider.load("connector-1")).thenReturn(Optional.of(externalConfig1));
+ when(provider.load("connector-2")).thenReturn(Optional.empty());
+
+ final List<ConnectorNode> results = repository.getConnectors();
+
+ assertEquals(2, results.size());
+ verify(connector1).setName("External Name 1");
+ verify(connector2, never()).setName(anyString());
+ }
+
+ @Test
+ public void testConfigureConnectorSavesToProviderBeforeModifyingNode() throws FlowUpdateException {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createConnectorNodeWithEmptyWorkingConfig("connector-1", "Test Connector");
+ repository.addConnector(connector);
+
+ when(provider.load("connector-1")).thenReturn(Optional.empty());
+
+ final StepConfiguration incomingConfig = new StepConfiguration(Map.of("prop1", new StringLiteralValue("new-value")));
+ repository.configureConnector(connector, "step1", incomingConfig);
+
+ final ArgumentCaptor<ConnectorWorkingConfiguration> configCaptor = ArgumentCaptor.forClass(ConnectorWorkingConfiguration.class);
+ verify(provider).save(eq("connector-1"), configCaptor.capture());
+
+ final ConnectorWorkingConfiguration savedConfig = configCaptor.getValue();
+ assertNotNull(savedConfig);
+ assertEquals("Test Connector", savedConfig.getName());
+
+ final List<VersionedConfigurationStep> savedSteps = savedConfig.getWorkingFlowConfiguration();
+ assertNotNull(savedSteps);
+ final VersionedConfigurationStep savedStep = savedSteps.stream()
+ .filter(s -> "step1".equals(s.getName())).findFirst().orElse(null);
+ assertNotNull(savedStep);
+ assertEquals("STRING_LITERAL", savedStep.getProperties().get("prop1").getValueType());
+ assertEquals("new-value", savedStep.getProperties().get("prop1").getValue());
+
+ verify(connector).setConfiguration("step1", incomingConfig);
+ }
+
+ @Test
+ public void testConfigureConnectorProviderSaveFailsDoesNotModifyNode() throws FlowUpdateException {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createConnectorNodeWithEmptyWorkingConfig("connector-1", "Test Connector");
+ repository.addConnector(connector);
+
+ when(provider.load("connector-1")).thenReturn(Optional.empty());
+ doThrow(new RuntimeException("Save failed")).when(provider).save(anyString(), any(ConnectorWorkingConfiguration.class));
+
+ final StepConfiguration incomingConfig = new StepConfiguration(Map.of("prop1", new StringLiteralValue("new-value")));
+
+ assertThrows(RuntimeException.class, () -> repository.configureConnector(connector, "step1", incomingConfig));
+
+ verify(connector, never()).setConfiguration(anyString(), any(StepConfiguration.class));
+ }
+
+ @Test
+ public void testConfigureConnectorMergesPartialStepConfig() throws FlowUpdateException {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createConnectorNodeWithEmptyWorkingConfig("connector-1", "Test Connector");
+ repository.addConnector(connector);
+
+ final VersionedConfigurationStep existingStep = createVersionedStep("step1",
+ Map.of("propA", createStringLiteralRef("old-A"), "propB", createStringLiteralRef("old-B")));
+ final ConnectorWorkingConfiguration existingConfig = new ConnectorWorkingConfiguration();
+ existingConfig.setName("Test Connector");
+ existingConfig.setWorkingFlowConfiguration(new ArrayList<>(List.of(existingStep)));
+ when(provider.load("connector-1")).thenReturn(Optional.of(existingConfig));
+
+ final Map<String, ConnectorValueReference> incomingProps = new HashMap<>();
+ incomingProps.put("propA", new StringLiteralValue("new-A"));
+ incomingProps.put("propC", new StringLiteralValue("new-C"));
+ final StepConfiguration incomingConfig = new StepConfiguration(incomingProps);
+
+ repository.configureConnector(connector, "step1", incomingConfig);
+
+ final ArgumentCaptor<ConnectorWorkingConfiguration> configCaptor = ArgumentCaptor.forClass(ConnectorWorkingConfiguration.class);
+ verify(provider).save(eq("connector-1"), configCaptor.capture());
+
+ final ConnectorWorkingConfiguration savedConfig = configCaptor.getValue();
+ final VersionedConfigurationStep savedStep = savedConfig.getWorkingFlowConfiguration().stream()
+ .filter(s -> "step1".equals(s.getName())).findFirst().orElse(null);
+ assertNotNull(savedStep);
+
+ final Map<String, VersionedConnectorValueReference> savedProps = savedStep.getProperties();
+ assertEquals("new-A", savedProps.get("propA").getValue());
+ assertEquals("old-B", savedProps.get("propB").getValue());
+ assertEquals("new-C", savedProps.get("propC").getValue());
+
+ verify(connector).setConfiguration("step1", incomingConfig);
+ }
+
+ @Test
+ public void testDiscardWorkingConfigurationCallsProviderDiscard() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createConnectorNodeWithEmptyWorkingConfig("connector-1", "Test Connector");
+ repository.addConnector(connector);
+
+ repository.discardWorkingConfiguration(connector);
+
+ verify(provider).discard("connector-1");
+ verify(provider, never()).save(anyString(), any(ConnectorWorkingConfiguration.class));
+ verify(connector).discardWorkingConfiguration();
+ }
+
+ @Test
+ public void testDiscardWorkingConfigurationProviderThrowsException() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createConnectorNodeWithEmptyWorkingConfig("connector-1", "Test Connector");
+ repository.addConnector(connector);
+
+ doThrow(new ConnectorConfigurationProviderException("Discard failed")).when(provider).discard("connector-1");
+
+ assertThrows(ConnectorConfigurationProviderException.class, () -> repository.discardWorkingConfiguration(connector));
+ }
+
+ @Test
+ public void testRemoveConnectorCallsProviderDelete() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final Connector mockConnector = mock(Connector.class);
+ final ConnectorNode connector = mock(ConnectorNode.class);
+ when(connector.getIdentifier()).thenReturn("connector-1");
+ when(connector.getConnector()).thenReturn(mockConnector);
+ repository.addConnector(connector);
+
+ repository.removeConnector("connector-1");
+
+ verify(provider).delete("connector-1");
+ }
+
+ @Test
+ public void testRemoveConnectorProviderThrowsException() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final Connector mockConnector = mock(Connector.class);
+ final ConnectorNode connector = mock(ConnectorNode.class);
+ when(connector.getIdentifier()).thenReturn("connector-1");
+ when(connector.getConnector()).thenReturn(mockConnector);
+ repository.addConnector(connector);
+
+ doThrow(new ConnectorConfigurationProviderException("Delete failed")).when(provider).delete("connector-1");
+
+ assertThrows(ConnectorConfigurationProviderException.class, () -> repository.removeConnector("connector-1"));
+ }
+
+ @Test
+ public void testUpdateConnectorSavesNameToProvider() {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ final ConnectorNode connector = createConnectorNodeWithEmptyWorkingConfig("connector-1", "Old Name");
+ repository.addConnector(connector);
+
+ repository.updateConnector(connector, "New Name");
+
+ final ArgumentCaptor<ConnectorWorkingConfiguration> configCaptor = ArgumentCaptor.forClass(ConnectorWorkingConfiguration.class);
+ verify(provider).save(eq("connector-1"), configCaptor.capture());
+ assertEquals("New Name", configCaptor.getValue().getName());
+
+ verify(connector).setName("New Name");
+ }
+
+ @Test
+ public void testInheritConfigurationDoesNotCallProvider() throws FlowUpdateException {
+ final ConnectorConfigurationProvider provider = mock(ConnectorConfigurationProvider.class);
+ final StandardConnectorRepository repository = createRepositoryWithProvider(provider);
+
+ when(provider.load("connector-1")).thenReturn(Optional.empty());
+
+ final ConnectorNode connector = mock(ConnectorNode.class);
+ when(connector.getIdentifier()).thenReturn("connector-1");
+ repository.addConnector(connector);
+
+ // Reset interactions so we can verify that inheritConfiguration itself does not call the provider
+ org.mockito.Mockito.reset(provider);
Review Comment:
Should avoid the fully-qualified class name :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NIFI-15355 Connector Configuration Repository [nifi]
Posted by "bbende (via GitHub)" <gi...@apache.org>.
bbende merged PR #10876:
URL: https://github.com/apache/nifi/pull/10876
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org