diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 00712470eed..00ff00a0e69 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -319,6 +319,9 @@ Bug Fixes * SOLR-5689: On reconnect, ZkController cancels election on first context rather than latest. (Gregory Chanan, Mark Miller via shalin) +* SOLR-5649: Clean up some minor ConnectionManager issues. + (Mark Miller, Gregory Chanan) + Optimizations ---------------------- diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java index 091529950c7..0e4884380c3 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java @@ -19,7 +19,6 @@ package org.apache.solr.common.cloud; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeoutException; import org.apache.solr.common.SolrException; @@ -34,9 +33,8 @@ public class ConnectionManager implements Watcher { .getLogger(ConnectionManager.class); private final String name; - private final CountDownLatch clientConnected = new CountDownLatch(1); - private boolean connected = false; + private volatile boolean connected = false; private final ZkClientConnectionStrategy connectionStrategy; @@ -47,7 +45,6 @@ public class ConnectionManager implements Watcher { private final OnReconnect onReconnect; private final BeforeReconnect beforeReconnect; - private volatile KeeperState state = KeeperState.Disconnected; private volatile boolean isClosed = false; private volatile boolean likelyExpired = true; @@ -122,11 +119,10 @@ public class ConnectionManager implements Watcher { return; } - state = event.getState(); + KeeperState state = event.getState(); if (state == KeeperState.SyncConnected) { connected(); - clientConnected.countDown(); connectionStrategy.connected(); } else if (state == KeeperState.Expired) { // we don't call disconnected because there @@ -168,8 +164,10 @@ public class ConnectionManager implements Watcher { closeKeeper(keeper); throw new RuntimeException(t); } - - connected(); + + // The new event thread will call connected + // we just start the reconnect thread and + // do nothing else if (onReconnect != null) { Thread thread = new Thread() {