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

    https://github.com/apache/nifi/pull/1301#discussion_r90969885
  
    --- 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 IOException(String.format("interrupted while waiting 
for ZooKeeper connection to %s", zooKeeperEndpointConfig), e);
    +        }
    +
    +        if (!connected) {
    +            throw new IOException(String.format("unable to connect to %s, 
state is %s", zooKeeperEndpointConfig, zooKeeper.getState()));
    --- End diff --
    
    Should we still try to close the zk connection to free any resources here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to