SOLR-5649: Clean up some minor ConnectionManager issues.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1567399 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-02-11 21:16:45 +00:00
parent d4a96018da
commit cf3bef28fc
2 changed files with 9 additions and 8 deletions

View File

@ -319,6 +319,9 @@ Bug Fixes
* SOLR-5689: On reconnect, ZkController cancels election on first context rather * SOLR-5689: On reconnect, ZkController cancels election on first context rather
than latest. (Gregory Chanan, Mark Miller via shalin) than latest. (Gregory Chanan, Mark Miller via shalin)
* SOLR-5649: Clean up some minor ConnectionManager issues.
(Mark Miller, Gregory Chanan)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -19,7 +19,6 @@ package org.apache.solr.common.cloud;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
@ -34,9 +33,8 @@ public class ConnectionManager implements Watcher {
.getLogger(ConnectionManager.class); .getLogger(ConnectionManager.class);
private final String name; private final String name;
private final CountDownLatch clientConnected = new CountDownLatch(1);
private boolean connected = false; private volatile boolean connected = false;
private final ZkClientConnectionStrategy connectionStrategy; private final ZkClientConnectionStrategy connectionStrategy;
@ -47,7 +45,6 @@ public class ConnectionManager implements Watcher {
private final OnReconnect onReconnect; private final OnReconnect onReconnect;
private final BeforeReconnect beforeReconnect; private final BeforeReconnect beforeReconnect;
private volatile KeeperState state = KeeperState.Disconnected;
private volatile boolean isClosed = false; private volatile boolean isClosed = false;
private volatile boolean likelyExpired = true; private volatile boolean likelyExpired = true;
@ -122,11 +119,10 @@ public class ConnectionManager implements Watcher {
return; return;
} }
state = event.getState(); KeeperState state = event.getState();
if (state == KeeperState.SyncConnected) { if (state == KeeperState.SyncConnected) {
connected(); connected();
clientConnected.countDown();
connectionStrategy.connected(); connectionStrategy.connected();
} else if (state == KeeperState.Expired) { } else if (state == KeeperState.Expired) {
// we don't call disconnected because there // we don't call disconnected because there
@ -169,7 +165,9 @@ public class ConnectionManager implements Watcher {
throw new RuntimeException(t); 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) { if (onReconnect != null) {
Thread thread = new Thread() { Thread thread = new Thread() {