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.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;

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.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);
}
/**