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

ASF GitHub Bot commented on NIFI-2605:
--------------------------------------

Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/900#discussion_r75871373
  
    --- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/leader/election/CuratorLeaderElectionManager.java
 ---
    @@ -218,14 +227,92 @@ public String getLeader(final String roleName) {
             return participantId;
         }
     
    +
    +    /**
    +     * Determines whether or not leader election has already begun for the 
role with the given name
    +     *
    +     * @param roleName the role of interest
    +     * @return <code>true</code> if leader election has already begun, 
<code>false</code> if it has not or if unable to determine this.
    +     */
    +    @Override
    +    public boolean isLeaderElected(final String roleName) {
    +        final String leaderAddress = determineLeaderExternal(roleName);
    +        return !StringUtils.isEmpty(leaderAddress);
    +    }
    +
    +
    +    /**
    +     * Use a new Curator client to determine which node is the elected 
leader for the given role.
    +     *
    +     * @param roleName the name of the role
    +     * @return the id of the elected leader, or <code>null</code> if no 
leader has been selected or if unable to determine
    +     *         the leader from ZooKeeper
    +     */
    +    private String determineLeaderExternal(final String roleName) {
    +        final CuratorFramework client = createClient();
    +        try {
    +            final LeaderSelectorListener electionListener = new 
LeaderSelectorListener() {
    +                @Override
    +                public void stateChanged(CuratorFramework client, 
ConnectionState newState) {
    +                }
    +
    +                @Override
    +                public void takeLeadership(CuratorFramework client) throws 
Exception {
    +                }
    +            };
    +
    +            final String electionPath = getElectionPath(roleName);
    +
    +            // Note that we intentionally do not auto-requeue here, and we 
do not start the selector. We do not
    +            // want to join the leader election. We simply want to observe.
    +            final LeaderSelector selector = new LeaderSelector(client, 
electionPath, electionListener);
    +
    +            try {
    +                final Participant leader = selector.getLeader();
    +                return leader == null ? null : leader.getId();
    +            } catch (final KeeperException.NoNodeException nne) {
    +                // If there is no ZNode, then there is no elected leader.
    +                return null;
    +            } catch (final Exception e) {
    +                logger.warn("Unable to determine the Elected Leader for 
role '{}' due to {}; assuming no leader has been elected", roleName, 
e.toString());
    +                if (logger.isDebugEnabled()) {
    +                    logger.warn("", e);
    +                }
    +
    +                return null;
    +            }
    +        } finally {
    +            client.close();
    +        }
    +    }
    +
    +    private CuratorFramework createClient() {
    +        // Create a new client because we don't want to try indefinitely 
for this to occur.
    +        final RetryPolicy retryPolicy = new RetryNTimes(10, 500);
    --- End diff --
    
    After 10 retries it will thrown an Exception, which will drop into the 
catch clause above, returning null.


> On restart of all nodes in nifi cluster one of the nodes failed to join the 
> cluster with fingerprint mismatch
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: NIFI-2605
>                 URL: https://issues.apache.org/jira/browse/NIFI-2605
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.0.0
>            Reporter: Arpit Gupta
>            Assignee: Mark Payne
>            Priority: Blocker
>             Fix For: 1.0.0
>
>
> Follow stack trace was present in the node that did not connect
> {code}
> 2016-08-18 12:04:55,628 INFO [Process Cluster Protocol Request-1] 
> o.a.n.c.p.impl.SocketProtocolListener Finished processing request 
> ea80ad62-585c-4460-9ee9-93cc12c8db54 (type=NODE_STATUS_CHANGE, length=1052 
> bytes) from host in 61 millis
> 2016-08-18 12:04:55,806 ERROR [main] o.a.nifi.controller.StandardFlowService 
> Failed to load flow from cluster due to: 
> org.apache.nifi.controller.UninheritableFlowException: Failed to connect node 
> to cluster because local flow is different than cluster flow.
> org.apache.nifi.controller.UninheritableFlowException: Failed to connect node 
> to cluster because local flow is different than cluster flow.
>         at 
> org.apache.nifi.controller.StandardFlowService.loadFromConnectionResponse(StandardFlowService.java:866)
>  ~[nifi-framework-core-1.0.0.jar:1.0.0]
>         at 
> org.apache.nifi.controller.StandardFlowService.load(StandardFlowService.java:492)
>  ~[nifi-framework-core-1.0.0.jar:1.0.0]
>         at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:746) 
> [nifi-jetty-1.0.0.jar:1.0.0]
>         at org.apache.nifi.NiFi.<init>(NiFi.java:137) 
> [nifi-runtime-1.0.0.jar:1.0.0]
>         at org.apache.nifi.NiFi.main(NiFi.java:227) 
> [nifi-runtime-1.0.0.jar:1.0.0]
> Caused by: org.apache.nifi.controller.UninheritableFlowException: Proposed 
> configuration is not inheritable by the flow controller because of flow 
> differences: Found difference in Flows:
> Local Fingerprint:   
> 7c84501d-d10c-407c-b9f3-1d80e38fe36a9d7d39c0-0156-1000-ffff-ffffc6ce3a7d9d7d3cd1-0156-1000-0000-0000
> Cluster Fingerprint: 9d89d844-0156-1000-e4bc-8ae5e0566749
> {code}
> Edit: As per the discussion below, this manifested due to 3 different 
> problems. The one being solved in this ticket is the one Mark addressed in 
> the linked PR, that a node will always register to be Cluster Coordinator 
> when it joins a cluster.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to