SOLR-9846: Try and make sure Overseer is always closed in tests and it's threads are done when it exists close.

This commit is contained in:
markrmiller 2017-02-12 14:58:06 -05:00
parent 1700e860ce
commit b5c7bd1d10
2 changed files with 24 additions and 2 deletions

View File

@ -44,6 +44,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.util.IOUtils; 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.common.util.Utils;
import org.apache.solr.core.CloudConfig; import org.apache.solr.core.CloudConfig;
import org.apache.solr.handler.admin.CollectionsHandler; import org.apache.solr.handler.admin.CollectionsHandler;
@ -489,6 +490,7 @@ public class Overseer implements Closeable {
this.zkController = zkController; this.zkController = zkController;
this.stats = new Stats(); this.stats = new Stats();
this.config = config; this.config = config;
assert ObjectReleaseTracker.track(this);
} }
public synchronized void start(String id) { public synchronized void start(String id) {
@ -540,11 +542,12 @@ public class Overseer implements Closeable {
} }
public synchronized void close() { public synchronized void close() {
if (closed || id == null) return; if (closed) return;
log.info("Overseer (id=" + id + ") closing"); log.info("Overseer (id=" + id + ") closing");
doClose(); doClose();
this.closed = true; this.closed = true;
assert ObjectReleaseTracker.release(this);
} }
private void doClose() { private void doClose() {
@ -562,6 +565,22 @@ public class Overseer implements Closeable {
arfoThread.interrupt(); 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; updaterThread = null;
ccThread = null; ccThread = null;
arfoThread = null; arfoThread = null;

View File

@ -75,6 +75,7 @@ import org.apache.solr.common.cloud.ZooKeeperException;
import org.apache.solr.common.params.CollectionParams; import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams; 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.StrUtils;
import org.apache.solr.common.util.URLUtil; import org.apache.solr.common.util.URLUtil;
import org.apache.solr.common.util.Utils; import org.apache.solr.common.util.Utils;
@ -417,6 +418,8 @@ public class ZkController {
}); });
init(registerOnReconnect); init(registerOnReconnect);
assert ObjectReleaseTracker.track(this);
} }
public int getLeaderVoteWait() { public int getLeaderVoteWait() {
@ -552,7 +555,7 @@ public class ZkController {
} }
} }
} }
assert ObjectReleaseTracker.release(this);
} }
/** /**