You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/07/22 15:47:10 UTC
[lucene-solr] branch reference_impl updated: @299 Keep improving Zk
ConnectionManager.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl by this push:
new 0db4b2a @299 Keep improving Zk ConnectionManager.
0db4b2a is described below
commit 0db4b2a15dba901b26521582347403218d2de838
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Jul 22 10:46:55 2020 -0500
@299 Keep improving Zk ConnectionManager.
---
.../apache/solr/common/cloud/ConnectionManager.java | 21 ++++++++++++---------
.../org/apache/solr/common/cloud/SolrZkClient.java | 3 ++-
2 files changed, 14 insertions(+), 10 deletions(-)
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 1c4a519..2862485 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
@@ -56,8 +56,8 @@ public class ConnectionManager implements Watcher, Closeable {
private volatile boolean isClosed = false;
- private CountDownLatch connectedLatch = new CountDownLatch(1);
- private CountDownLatch disconnectedLatch = new CountDownLatch(1);
+ private volatile CountDownLatch connectedLatch = new CountDownLatch(1);
+ private volatile CountDownLatch disconnectedLatch = new CountDownLatch(1);
private volatile DisconnectListener disconnectListener;
private volatile int lastConnectedState = 0;
@@ -287,12 +287,14 @@ public class ConnectionManager implements Watcher, Closeable {
log.info("Close called on ZK ConnectionManager");
this.isClosed = true;
this.likelyExpiredState = LikelyExpiredState.EXPIRED;
- try {
- waitForDisconnected(5000);
- } catch (InterruptedException e) {
- ParWork.propegateInterrupt(e);
- } catch (TimeoutException e) {
- log.warn("Timeout waiting for ZooKeeper client to disconnect");
+ if (client.isConnected()) {
+ try {
+ waitForDisconnected(5000);
+ } catch (InterruptedException e) {
+ ParWork.propegateInterrupt(e);
+ } catch (TimeoutException e) {
+ log.warn("Timeout waiting for ZooKeeper client to disconnect");
+ }
}
}
@@ -320,7 +322,8 @@ public class ConnectionManager implements Watcher, Closeable {
public void waitForDisconnected(long waitForDisconnected)
throws InterruptedException, TimeoutException {
- if (!client.isConnected()) return;
+
+ if (!client.isConnected() || lastConnectedState != 1) return;
boolean success = disconnectedLatch.await(1000, TimeUnit.MILLISECONDS);
if (!success) {
throw new TimeoutException("Timeout waiting to disconnect from ZooKeeper");
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
index a2ceacf..fa2db3e 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
@@ -862,7 +862,8 @@ public class SolrZkClient implements Closeable {
isClosed = true;
try (ParWork worker = new ParWork(this, true)) {
- worker.add("zkClient", connManager, keeper);
+ worker.add("keeper", keeper);
+ worker.add("connectionManager", connManager);
worker.add("zkExecutors", zkCallbackExecutor, zkConnManagerCallbackExecutor);
}
assert ObjectReleaseTracker.release(this);