This is an automated email from the ASF dual-hosted git repository.
markap14 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new bcf625f NIFI-7920: When node that is connected to cluster is asked to
reconnect, ensure that it relinquishes role of Cluster Coordinator and Primary
Node
bcf625f is described below
commit bcf625f4c8cf8a7733cd8efad0b0b1be940ca253
Author: Mark Payne <[email protected]>
AuthorDate: Tue Oct 13 11:54:57 2020 -0400
NIFI-7920: When node that is connected to cluster is asked to reconnect,
ensure that it relinquishes role of Cluster Coordinator and Primary Node
---
.../src/main/java/org/apache/nifi/controller/FlowController.java | 8 ++++++--
.../main/java/org/apache/nifi/controller/StandardFlowService.java | 7 +++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
index f86ea8e..33ca578 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
@@ -2378,8 +2378,7 @@ public class FlowController implements
ReportingTaskProvider, Authorizable, Node
}
if (!clustered) {
- leaderElectionManager.unregister(ClusterRoles.PRIMARY_NODE);
-
leaderElectionManager.unregister(ClusterRoles.CLUSTER_COORDINATOR);
+ onClusterDisconnect();
}
// update the heartbeat bean
@@ -2389,6 +2388,11 @@ public class FlowController implements
ReportingTaskProvider, Authorizable, Node
}
}
+ public void onClusterDisconnect() {
+ leaderElectionManager.unregister(ClusterRoles.PRIMARY_NODE);
+ leaderElectionManager.unregister(ClusterRoles.CLUSTER_COORDINATOR);
+ }
+
public LeaderElectionManager getLeaderElectionManager() {
return leaderElectionManager;
}
diff --git
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
index aa86672..c794dc4 100644
---
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
+++
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
@@ -636,6 +636,13 @@ public class StandardFlowService implements FlowService,
ProtocolHandler {
try {
logger.info("Processing reconnection request from cluster
coordinator.");
+ // We are no longer connected to the cluster. But the intent is to
reconnect to the cluster.
+ // So we don't want to call FlowController.setClustered(false,
null).
+ // It is important, though, that we perform certain tasks, such as
un-registering the node as Cluster Coordinator/Primary Node
+ if (controller.isConnected()) {
+ controller.onClusterDisconnect();
+ }
+
// reconnect
ConnectionResponse connectionResponse = new
ConnectionResponse(getNodeId(), request.getDataFlow(),
request.getInstanceId(),
request.getNodeConnectionStatuses(), request.getComponentRevisions());