Pierre Villard created NIP-9:
--------------------------------
Summary: Possibility to drop individual keys in component state
Key: NIP-9
URL: https://issues.apache.org/jira/browse/NIP-9
Project: NiFi Improvement Proposal
Issue Type: Improvement
Reporter: Pierre Villard
Assignee: Pierre Villard
h3. Motivation
Currently a component can specify if state will be stored or not using the
annotation
{code:java}
@Stateful(scopes = Scope.CLUSTER, description = "xyz") {code}
And the state is a Map<String, String>.
Through the UI / APIs, it is possible to get the state using:
{code:java}
GET .../{id}/state{code}
and to clear the state using:
{code:java}
POST .../{id}/state/clear-requests{code}
Note that for the above request, we accept a ComponentStateEntity for the
payload but this is completely ignored at the moment in the backend code and
the UI always sends {} for the payload.
In some cases, it would be useful to provide the option to the user to remove
only a specific key from the state and not clear the entirety of the state.
However, this is risky and highly depends on the code of the component and how
the state is used/managed.
This is why this feature should NOT be enabled by default, and could be turned
on via a new attribute of the annotation in the code of the component. This
would be the responsibility of the developer to know if this is OK to have the
option of removing individual keys from the state while the component is
stopped.
h3. Scope
Add
{code:java}
boolean canDropKey() default false; {code}
to org.apache.nifi.annotation.behavior.Stateful
Once we have this API change, some straight forward changes would be required
in the classes where we currently implement clearing the state for a given
component ID by also passing the component state entity up until
StandardComponentStateDAO class.
For components where this improvement is desired, the annotation would become
something like:
{code:java}
@Stateful(scopes = Scope.CLUSTER, description = "xyz", canDropKey = true)
{code}
h3. Compatibility
Fully backward compatible.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)