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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
