From b5c7bd1d10f3df8b2a622f3d76bee72f028cc483 Mon Sep 17 00:00:00 2001 From: markrmiller Date: Sun, 12 Feb 2017 14:58:06 -0500 Subject: [PATCH] SOLR-9846: Try and make sure Overseer is always closed in tests and it's threads are done when it exists close. --- .../java/org/apache/solr/cloud/Overseer.java | 21 ++++++++++++++++++- .../org/apache/solr/cloud/ZkController.java | 5 ++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java index a618874f3ba..0b74ccba180 100644 --- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java +++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java @@ -44,6 +44,7 @@ import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.util.IOUtils; +import org.apache.solr.common.util.ObjectReleaseTracker; import org.apache.solr.common.util.Utils; import org.apache.solr.core.CloudConfig; import org.apache.solr.handler.admin.CollectionsHandler; @@ -489,6 +490,7 @@ public class Overseer implements Closeable { this.zkController = zkController; this.stats = new Stats(); this.config = config; + assert ObjectReleaseTracker.track(this); } public synchronized void start(String id) { @@ -540,11 +542,12 @@ public class Overseer implements Closeable { } public synchronized void close() { - if (closed || id == null) return; + if (closed) return; log.info("Overseer (id=" + id + ") closing"); doClose(); this.closed = true; + assert ObjectReleaseTracker.release(this); } private void doClose() { @@ -562,6 +565,22 @@ public class Overseer implements Closeable { arfoThread.interrupt(); } + if (updaterThread != null) { + try { + updaterThread.join(); + } catch (InterruptedException e) {} + } + if (ccThread != null) { + try { + ccThread.join(); + } catch (InterruptedException e) {} + } + if (arfoThread != null) { + try { + arfoThread.join(); + } catch (InterruptedException e) {} + } + updaterThread = null; ccThread = null; arfoThread = null; diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index eba7067a90a..89a88e38e46 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -75,6 +75,7 @@ import org.apache.solr.common.cloud.ZooKeeperException; import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.SolrParams; +import org.apache.solr.common.util.ObjectReleaseTracker; import org.apache.solr.common.util.StrUtils; import org.apache.solr.common.util.URLUtil; import org.apache.solr.common.util.Utils; @@ -417,6 +418,8 @@ public class ZkController { }); init(registerOnReconnect); + + assert ObjectReleaseTracker.track(this); } public int getLeaderVoteWait() { @@ -552,7 +555,7 @@ public class ZkController { } } } - + assert ObjectReleaseTracker.release(this); } /**