exceptionfactory commented on code in PR #11796:
URL: https://github.com/apache/nifi/pull/11796#discussion_r4586660457
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java:
##########
@@ -3285,11 +3285,21 @@ public LeaderElectionManager getLeaderElectionManager()
{
*/
@Override
public boolean isPrimary() {
- return isClustered() && leaderElectionManager != null &&
leaderElectionManager.isLeader(ClusterRoles.PRIMARY_NODE);
+ try {
+ return isClustered() && leaderElectionManager != null &&
leaderElectionManager.isLeader(ClusterRoles.PRIMARY_NODE);
+ } catch (final Exception e) {
+ LOG.warn("Failed to determine whether this instance is the primary
node. Assuming that it is not.", e);
+ return false;
+ }
}
public boolean isClusterCoordinator() {
- return isClustered() && leaderElectionManager != null &&
leaderElectionManager.isLeader(ClusterRoles.CLUSTER_COORDINATOR);
+ try {
+ return isClustered() && leaderElectionManager != null &&
leaderElectionManager.isLeader(ClusterRoles.CLUSTER_COORDINATOR);
+ } catch (final Exception e) {
+ LOG.warn("Failed to determine whether this instance is the cluster
coordinator. Assuming that it is not.", e);
Review Comment:
```suggestion
LOG.warn("Failed to determine Leader for Role [Cluster
Coordinator]", e);
```
##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java:
##########
@@ -3285,11 +3285,21 @@ public LeaderElectionManager getLeaderElectionManager()
{
*/
@Override
public boolean isPrimary() {
- return isClustered() && leaderElectionManager != null &&
leaderElectionManager.isLeader(ClusterRoles.PRIMARY_NODE);
+ try {
+ return isClustered() && leaderElectionManager != null &&
leaderElectionManager.isLeader(ClusterRoles.PRIMARY_NODE);
+ } catch (final Exception e) {
+ LOG.warn("Failed to determine whether this instance is the primary
node. Assuming that it is not.", e);
Review Comment:
```suggestion
LOG.warn("Failed to determine Leader for Role [Primary Node]",
e);
```
--
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]