Vinz2168 opened a new pull request, #11808: URL: https://github.com/apache/nifi/pull/11808
# Summary [NIFI-16457](https://issues.apache.org/jira/browse/NIFI-16457) The C2 protocol already defines `OperationType.CLEAR` with `OperandType.CONNECTION` as its only operand, but MiNiFi Java has no handler for it. A C2 server sending this operation never receives an acknowledgement, and there is no remote way to empty a connection queue (the equivalent of "Empty Queue" on the NiFi canvas), for example to recover an agent stuck on back pressure. This change implements the operation following the same structure introduced for processor start/stop in NIFI-15017: - `ConnectionQueueStrategy` interface and `ClearConnectionOperationHandler` in `c2-client-service`. The handler reads the `connectionId` argument and returns `NOT_APPLIED` when it is missing. - `DefaultConnectionQueueStrategy` in `minifi-framework-core`, which looks up the connection through `FlowManager` and calls `FlowFileQueue.dropFlowFiles(...)`, the same mechanism `DefaultUpdateConfigurationStrategy` already uses to empty queues removed by a flow update. The drop request is asynchronous, so the strategy waits for completion up to 30 seconds: - `FULLY_APPLIED` when the drop request completes - `PARTIALLY_APPLIED` when it is still running after the timeout - `NOT_APPLIED` when the connection does not exist or the drop request fails - The handler is registered in `C2NifiClientService`, so `CLEAR`/`CONNECTION` is advertised in the agent's supported operations. Example operation: ```json { "identifier": "op-1", "operation": "CLEAR", "operand": "CONNECTION", "args": { "connectionId": "<connection instance identifier>" } } ``` Verified with a MiNiFi assembly built from this branch, connected to a test C2 server: - `CLEAR`/`CONNECTION` is listed in the agent manifest `supportedOperations` - after stopping the destination processor, the queue grew to 13 FlowFiles; the CLEAR operation was acknowledged with `FULLY_APPLIED` and the agent logged `Cleared queue of connection ..., dropped QueueSize[FlowFiles=15, ContentSize=150 Bytes]` - CLEAR on an unknown connection id was acknowledged with `NOT_APPLIED` Unit tests cover the handler and the strategy. # Tracking Please complete the following tracking steps prior to pull request creation. ### 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 - [x] Pull Request based on current revision of the `main` branch - [x] Pull Request refers to a feature branch with one commit containing changes # Verification Please indicate the verification steps performed prior to pull request creation. ### Build - [x] Build completed using `./mvnw clean install -P contrib-check` - [x] JDK 21 - [ ] JDK 25 ### Licensing - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html) - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files ### Documentation - [ ] Documentation formatting appears as expected in rendered files 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
