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

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

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

    https://github.com/apache/nifi/pull/1301#discussion_r90969779
  
    --- Diff: 
nifi-toolkit/nifi-toolkit-zookeeper-migrator/src/main/java/org/apache/nifi/toolkit/zkmigrator/ZooKeeperMigrator.java
 ---
    @@ -284,8 +287,29 @@ private Stat transmitNode(ZooKeeper zooKeeper, 
DataStatAclNode node) {
         }
     
         private ZooKeeper getZooKeeper(ZooKeeperEndpointConfig 
zooKeeperEndpointConfig, AuthMode authMode, byte[] authData) throws IOException 
{
    +        CountDownLatch connectionLatch = new CountDownLatch(1);
             ZooKeeper zooKeeper = new 
ZooKeeper(zooKeeperEndpointConfig.getConnectString(), 3000, watchedEvent -> {
    +            if (LOGGER.isDebugEnabled()) {
    +                LOGGER.debug("ZooKeeper server state changed to {} in {}", 
watchedEvent.getState(), zooKeeperEndpointConfig);
    +            }
    +            if 
(watchedEvent.getType().equals(Watcher.Event.EventType.None) && 
watchedEvent.getState().equals(Watcher.Event.KeeperState.SyncConnected)) {
    +                connectionLatch.countDown();
    +            }
             });
    +
    +        final boolean connected;
    +        try {
    +            connected = connectionLatch.await(5, TimeUnit.SECONDS);
    +        } catch (InterruptedException e) {
    +            Thread.currentThread().interrupt();
    +            throw new RuntimeException(String.format("interrupted while 
waiting for ZooKeeper connection to %s", zooKeeperEndpointConfig), e);
    +        }
    +
    +        if (!connected) {
    --- End diff --
    
    Should we still try to close the zk connection to free any resources here?


> ZooKeeper Migrator does not wait for connection before attempting to 
> read/write to ZooKeeper
> --------------------------------------------------------------------------------------------
>
>                 Key: NIFI-3150
>                 URL: https://issues.apache.org/jira/browse/NIFI-3150
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Tools and Build
>    Affects Versions: 1.1.0
>            Reporter: Jeff Storck
>            Assignee: Jeff Storck
>
> While running NiFi in a 3-node cluster, attempting to read or write ZK data 
> to the ZK ensemble results in intermittent connection loss exceptions because 
> the migrator is not waiting for the asynchronous connection method in ZK to 
> report that the client has completely connected.



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

Reply via email to