markap14 opened a new pull request, #11837:
URL: https://github.com/apache/nifi/pull/11837

   <!-- SPDX-License-Identifier: Apache-2.0 -->
   
   # Summary
   
   [NIFI-16494](https://issues.apache.org/jira/browse/NIFI-16494)
   
   Implements the framework portion of 
[NIP-50](https://issues.apache.org/jira/browse/NIP-50). This depends on 
apache/nifi-api#112 
([NIFI-16493](https://issues.apache.org/jira/browse/NIFI-16493)) and sets 
`nifi-api.version` to `2.15.0-SNAPSHOT`, so it stays a draft until that PR is 
merged and published.
   
   - `StateProvider` gets a default `patchState` that retrieves the current 
state, applies the changes, and calls `replace` until it succeeds. Providers 
that can update individual keys can override it.
   - `StandardProcessSession` remembers whether the pending state update for 
each scope is a whole-map update (from `setState`) or a patch (from 
`patchState`). On commit, a patch is sent to the `StateManager` as a 
`patchState` call containing only the patched keys. The patch is applied even 
if another writer changed the stored state since the session read it, and keys 
outside the patch keep their stored values. Whole-map updates keep the existing 
version check. Calling `setState` after `patchState` in the same session 
replaces the patch with the new whole map.
   - `StandardStateManager`, `TaskTerminationAwareStateManager`, 
`StandardStateManagerProvider`, `ManagedStateProvider`, 
`BatchingSessionFactory`, `WeakHashMapProcessSessionFactory`, the Groovyx 
`ProcessSessionWrap`, and `MockProcessSession` pass `patchState` through 
instead of falling back to a whole-map replacement.
   - `WriteAheadLocalStateProvider` writes only the patched keys to its 
journal. `StateMapSerDe` moves to version 1, which can record either a full 
state map or a patch applied on top of the previous record for that component. 
Snapshots still hold full state maps. Journals written by version 0 can still 
be read. NiFi versions without this change cannot read a version 1 journal, so 
going back to an older NiFi after state has been written is not supported.
   - The `VerifyLocalClusterStateService` and `MultiKeyState` system test 
extensions use `patchState`, and the Developer Guide describes it.
   
   Tests:
   
   - `StandardProcessSessionIT` checks that a session patch reaches the 
`StateManager` as a `patchState` call, that several patches in one session are 
combined, that `setState` after `patchState` replaces the patch, and that a 
patch is applied on commit even after another writer updated the state.
   - `TestStateMapSerDe` checks that a patch journal entry round-trips on top 
of a previous record.
   - `TestWriteAheadLocalStateProvider` checks that a patch is written to the 
journal as only the patched keys and that state recovers correctly after 
restart.
   - `AbstractTestStateProvider`, `KubernetesConfigMapStateProviderTest`, 
`TestMockProcessSession`, and `ClusterStateKeyDropIT` cover `patchState` for 
the other providers, the mock session, and a cluster.
   
   # 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
   
   - [ ] Build completed using `./mvnw clean install -P contrib-check`
     - [ ] 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
   
   - [x] Documentation formatting appears as expected in rendered files
   


-- 
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]

Reply via email to