kevdoran opened a new pull request, #10857: URL: https://github.com/apache/nifi/pull/10857
<!-- 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-15355](https://issues.apache.org/jira/browse/NIFI-15355) This PR refactors the Connector API to create clean extension points for third-party implementations. The primary goal is to allow external developers to implement custom `ConnectorRepository` and `ConnectorLifecycleManager` instances without requiring changes to NiFi core. ## Motivation The original `ConnectorRepository` interface in `nifi-framework-core-api` was entangled with internal framework dependencies (like `FlowManager`) that cannot be exposed as a stable public API. This refactoring creates a layered architecture where: - **Public extension points** live in `nifi-framework-api` with minimal, stable dependencies - **Internal orchestration** remains in `nifi-framework-core-api` and `nifi-framework-core` ## Updated Internal Arch Diagram ``` ┌─────────────────────────────────────────────────────────────────────────────────┐ │ nifi-web-api │ │ ┌───────────────────┐ │ │ │ ConnectorResource │ ◄── REST API endpoints (/connectors/*) │ │ └─────────┬─────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────┐ │ │ │StandardNiFiServiceFacade│ ◄── Service layer / orchestration │ │ └─────────┬───────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ StandardConnectorDAO│ ◄── Data Access Object │ │ └─────────┬───────────┘ │ └────────────┼────────────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────────────────────┐ │ nifi-framework-core │ │ ┌───────────────┐ │ │ │FlowController │ ◄── Central controller, owns FlowManager & ConnectorManager │ │ └───────┬───────┘ │ │ │ │ │ ├──────────────────────┐ │ │ ▼ ▼ │ │ ┌──────────────────┐ ┌─────────────────────────┐ │ │ │ FlowManager │ │ StandardConnectorManager│ ◄── Internal orchestrator │ │ │ │ │ (ConnectorManager) │ │ │ │ -createConnector │ └───────────┬─────────────┘ │ │ │ -removeConnector │ │ │ │ └──────────────────┘ │ delegates to │ │ ┌──────────┴──────────┐ │ │ ▼ ▼ │ │ ┌──────────────────────┐ ┌─────────────────────────────┐ │ │ │FlowJsonConnectorRepo │ │StandardConnectorLifecycleMgr│ │ │ │ (default impl) │ │ (default impl) │ │ │ └──────────┬───────────┘ └──────────────┬──────────────┘ │ └───────────────────────┼─────────────────────────────┼───────────────────────────┘ │ implements │ implements ┌───────────────────────┼─────────────────────────────┼───────────────────────────┐ │ ▼ ▼ nifi-framework-api │ │ ┌─────────────────────────────┐ ┌────────────────────────────────┐ │ │ │ ConnectorRepository │ │ ConnectorLifecycleManager │ │ │ │ «interface» │ │ «interface» │ │ │ │ │ │ │ │ │ │ + save(record) │ │ + startConnector(node) │ │ │ │ + load(id) / loadAll() │ │ + stopConnector(node) │ │ │ │ + delete(id) │ │ + restartConnector(node) │ │ │ │ + prepareForUpdate(id) │ │ + getConnectorState(id) │ │ │ │ + supportsExternalMod() │ │ │ │ │ └─────────────────────────────┘ └────────────────────────────────┘ │ │ ▲ ▲ │ │ │ │ │ │ ┌─────────┴─────────┐ ┌────────┴────────┐ │ │ │ EXTENSION POINT │ │ EXTENSION POINT │ │ │ │ (3rd party impl) │ │ (3rd party impl)│ │ │ └───────────────────┘ └─────────────────┘ │ │ │ │ Examples: │ │ - S3ConnectorRepository - Custom lifecycle with │ │ - DatabaseConnectorRepository external orchestration │ └─────────────────────────────────────────────────────────────────────────────────┘ ``` **Data Flow for Creating a Connector:** ``` REST Request → ConnectorResource → ServiceFacade → ConnectorDAO → FlowManager.createConnector() → ConnectorManager.addConnector() → ConnectorRepository.save() ``` **Data Flow for Updating a Connector:** ``` REST Request → ... → ConnectorDAO → ConnectorManager.applyUpdate() → ConnectorRepository.prepareForUpdate() [can reject → 409 Conflict] → ConnectorLifecycleManager.stopConnector() → apply changes → ConnectorLifecycleManager.startConnector() → ConnectorRepository.completeUpdate() ``` ## Key Changes ### New Public Extension Points (`nifi-framework-api`) | Interface | Purpose | |-----------|---------| | `ConnectorRepository` | Persistence of connector configuration (save, load, delete) | | `ConnectorLifecycleManager` | Runtime lifecycle management (start, stop, restart) | | `SecretsProvider` | Pluggable secrets management | | `PersistedConnectorRecord` | Data transfer object for persisted connector state | | `ConnectorRepositoryContext` | Initialization context for repository implementations | | `ConnectorLifecycleContext` | Initialization context for lifecycle implementations | ### Internal Framework Changes - Renamed the internal `ConnectorRepository` to `ConnectorManager` in `nifi-framework-core-api` - `ConnectorManager` now orchestrates between the pluggable `ConnectorRepository` and `ConnectorLifecycleManager` - Created `FlowJsonConnectorRepository` as the default implementation (embeds connectors in `flow.json.gz`) - Created `StandardConnectorLifecycleManager` as the default lifecycle implementation ### External Modification Support Third-party repositories can support external changes to connector configuration (e.g., files modified directly in S3 or records updated in a database): - `supportsExternalModification()` - indicates if external changes are supported - `prepareForUpdate()` / `completeUpdate()` - transactional update semantics allowing the repository to "vote" on updates - `ConnectorUpdateRejectedException` - returns HTTP 409 Conflict when updates are rejected ### Configuration Implementations are configurable via `nifi.properties`: ``` nifi.connector.repository.implementation=org.apache.nifi.components.connector.FlowJsonConnectorRepository nifi.connector.lifecycle.manager.implementation=org.apache.nifi.components.connector.StandardConnectorLifecycleManager ``` ### Issue Tracking - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created ### Pull Request Tracking - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000` - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000` - [x] Pull request contains [commits signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) with a registered key indicating `Verified` status ### Pull Request Formatting - [ ] Pull Request based on current revision of the `main` branch - [x] Pull Request refers to a feature branch with one commit containing changes -- 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]
