SOLR-4554: There are some test fails because of a wait loop that causes lingering threads.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1454932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-03-10 22:19:48 +00:00
parent a60156aae3
commit a0ef70931c
6 changed files with 34 additions and 6 deletions

View File

@ -581,12 +581,26 @@ public class Overseer {
public void close() {
isClosed = true;
if (updaterThread != null) {
updaterThread.close();
updaterThread.interrupt();
try {
updaterThread.close();
updaterThread.interrupt();
} catch (Throwable t) {
log.error("Error closing updaterThread", t);
}
}
if (ccThread != null) {
ccThread.close();
ccThread.interrupt();
try {
ccThread.close();
ccThread.interrupt();
} catch (Throwable t) {
log.error("Error closing ccThread", t);
}
}
try {
reader.close();
} catch (Throwable t) {
log.error("Error closing zkStateReader", t);
}
}

View File

@ -348,6 +348,12 @@ public final class ZkController {
log.error("Error closing overseer", t);
}
try {
zkStateReader.close();
} catch(Throwable t) {
log.error("Error closing zkStateReader", t);
}
try {
zkClient.close();;
} catch(Throwable t) {

View File

@ -284,6 +284,10 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
zkClient.close();
}
if (reader != null) {
reader.close();
}
for (CoreContainer cc : containerMap.values()) {
if (!cc.isShutDown()) {
cc.shutdown();

View File

@ -451,6 +451,7 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
@Override
public void tearDown() throws Exception {
zkClient.close();
zkStateReader.close();
server.shutdown();
super.tearDown();
}

View File

@ -133,6 +133,8 @@ public class ZkStateReader {
private Aliases aliases = new Aliases();
private volatile boolean closed = false;
public ZkStateReader(SolrZkClient zkClient) {
this.zkClient = zkClient;
initZkCmdExecutor(zkClient.getZkClientTimeout());
@ -437,6 +439,7 @@ public class ZkStateReader {
}
public void close() {
this.closed = true;
if (closeClient) {
zkClient.close();
}
@ -469,7 +472,7 @@ public class ZkStateReader {
*/
public Replica getLeaderRetry(String collection, String shard, int timeout) throws InterruptedException {
long timeoutAt = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < timeoutAt) {
while (System.currentTimeMillis() < timeoutAt && !closed) {
if (clusterState != null) {
Replica replica = clusterState.getLeader(collection, shard);
if (replica != null && getClusterState().liveNodesContain(replica.getNodeName())) {

View File

@ -85,7 +85,7 @@ public class CloudSolrServerTest extends AbstractFullDistribZkTestBase {
public CloudSolrServerTest() {
super();
sliceCount = 2;
shardCount = 6;
shardCount = 4;
}
@Override