[ 
https://issues.apache.org/jira/browse/NIP-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18100554#comment-18100554
 ] 

David Handermann commented on NIP-37:
-------------------------------------

Thanks for proposing this improvement [~pvillard], it should provide a better 
interface surface that clarifies that state of the Node.

The only adjustment I recommend is an additional enumerated type for 
unclustered or standalone, as opposed to implying to from the empty status.

> Expose Node Connection State through NodeTypeProvider
> -----------------------------------------------------
>
>                 Key: NIP-37
>                 URL: https://issues.apache.org/jira/browse/NIP-37
>             Project: NiFi Improvement Proposal
>          Issue Type: Improvement
>            Reporter: Pierre Villard
>            Priority: Major
>
> h2. Motivation
> *NodeTypeProvider* currently exposes cluster status through several boolean 
> methods:
>  * *isConfiguredForClustering()* indicates whether the NiFi instance is 
> configured as a cluster node.
>  * *isClustered()* indicates whether the node is connected or attempting to 
> connect.
>  * *isConnected()* indicates whether the node is fully connected.
> These booleans do not provide enough information to describe the node 
> lifecycle accurately. In particular, components can be loaded and validated 
> while a node is joining a cluster.
> During clustered startup, the Cluster Coordinator marks the local node as 
> *CONNECTING* before the cluster flow is loaded. However, 
> *FlowController.isClustered()* is not set to true until after flow 
> synchronization completes. Setting it earlier is not appropriate because 
> *FlowController.setClustered(true, ...)* also starts cluster-related behavior 
> such as heartbeating, leader-election participation, load balancing, and 
> Remote Process Group reinitialization.
> As a result, a component loaded during flow synchronization can observe:
>  * isConfiguredForClustering() == true
>  * isClustered() == false
>  * isConnected() == false
> From these values, the component cannot distinguish a standalone or 
> disconnected node from a node that is actively connecting to a cluster. 
> Components that need to validate behavior based on cluster topology can 
> therefore produce incorrect transient validation results during startup.
> NiFi already models this lifecycle using {*}NodeConnectionState{*}, with 
> states such as {*}CONNECTING{*}, {*}CONNECTED{*}, {*}DISCONNECTING{*}, and 
> {*}DISCONNECTED{*}. This proposal makes that state available through 
> {*}NodeTypeProvide{*}` instead of requiring components to infer it from 
> multiple booleans.
> h2. Scope
> Add the following method to {*}NodeTypeProvider{*}:
> {code:java}
> default Optional<NodeConnectionState> getNodeConnectionState() {
>     return Optional.empty();
> }{code}
> The default implementation preserves compatibility with existing 
> implementations of {*}NodeTypeProvider{*}.
> The proposed semantics are:
>  * *Optional.empty()* means that the provider does not expose a cluster 
> connection state, including providers representing standalone NiFi instances.
>  * A present value represents the current connection lifecycle state of the 
> local node.
>  * *CONNECTING* means that the node is joining the cluster but has not 
> completed connection.
>  * *CONNECTED* means that the node has completed the connection process.
>  * Other existing *NodeConnectionState* values retain their current meanings.
> *NodeConnectionState* currently belongs to the 
> nifi-framework-cluster-protocol module, which is in nifi. To expose it from 
> {*}NodeTypeProvider{*}, move *NodeConnectionState* into the nifi-api artifact 
> while retaining its existing package name, enum constants, ordering, and 
> serialization behavior.
> Retaining the fully qualified class name avoids requiring source changes in 
> existing NiFi framework code that uses the enum.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to