mirror of https://github.com/apache/lucene.git
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:
parent
a60156aae3
commit
a0ef70931c
|
@ -581,12 +581,26 @@ public class Overseer {
|
||||||
public void close() {
|
public void close() {
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
if (updaterThread != null) {
|
if (updaterThread != null) {
|
||||||
|
try {
|
||||||
updaterThread.close();
|
updaterThread.close();
|
||||||
updaterThread.interrupt();
|
updaterThread.interrupt();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
log.error("Error closing updaterThread", t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ccThread != null) {
|
if (ccThread != null) {
|
||||||
|
try {
|
||||||
ccThread.close();
|
ccThread.close();
|
||||||
ccThread.interrupt();
|
ccThread.interrupt();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
log.error("Error closing ccThread", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
reader.close();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
log.error("Error closing zkStateReader", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,6 +348,12 @@ public final class ZkController {
|
||||||
log.error("Error closing overseer", t);
|
log.error("Error closing overseer", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
zkStateReader.close();
|
||||||
|
} catch(Throwable t) {
|
||||||
|
log.error("Error closing zkStateReader", t);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
zkClient.close();;
|
zkClient.close();;
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
|
|
|
@ -284,6 +284,10 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
||||||
zkClient.close();
|
zkClient.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reader != null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
|
||||||
for (CoreContainer cc : containerMap.values()) {
|
for (CoreContainer cc : containerMap.values()) {
|
||||||
if (!cc.isShutDown()) {
|
if (!cc.isShutDown()) {
|
||||||
cc.shutdown();
|
cc.shutdown();
|
||||||
|
|
|
@ -451,6 +451,7 @@ public class LeaderElectionTest extends SolrTestCaseJ4 {
|
||||||
@Override
|
@Override
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
zkClient.close();
|
zkClient.close();
|
||||||
|
zkStateReader.close();
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,8 @@ public class ZkStateReader {
|
||||||
|
|
||||||
private Aliases aliases = new Aliases();
|
private Aliases aliases = new Aliases();
|
||||||
|
|
||||||
|
private volatile boolean closed = false;
|
||||||
|
|
||||||
public ZkStateReader(SolrZkClient zkClient) {
|
public ZkStateReader(SolrZkClient zkClient) {
|
||||||
this.zkClient = zkClient;
|
this.zkClient = zkClient;
|
||||||
initZkCmdExecutor(zkClient.getZkClientTimeout());
|
initZkCmdExecutor(zkClient.getZkClientTimeout());
|
||||||
|
@ -437,6 +439,7 @@ public class ZkStateReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
this.closed = true;
|
||||||
if (closeClient) {
|
if (closeClient) {
|
||||||
zkClient.close();
|
zkClient.close();
|
||||||
}
|
}
|
||||||
|
@ -469,7 +472,7 @@ public class ZkStateReader {
|
||||||
*/
|
*/
|
||||||
public Replica getLeaderRetry(String collection, String shard, int timeout) throws InterruptedException {
|
public Replica getLeaderRetry(String collection, String shard, int timeout) throws InterruptedException {
|
||||||
long timeoutAt = System.currentTimeMillis() + timeout;
|
long timeoutAt = System.currentTimeMillis() + timeout;
|
||||||
while (System.currentTimeMillis() < timeoutAt) {
|
while (System.currentTimeMillis() < timeoutAt && !closed) {
|
||||||
if (clusterState != null) {
|
if (clusterState != null) {
|
||||||
Replica replica = clusterState.getLeader(collection, shard);
|
Replica replica = clusterState.getLeader(collection, shard);
|
||||||
if (replica != null && getClusterState().liveNodesContain(replica.getNodeName())) {
|
if (replica != null && getClusterState().liveNodesContain(replica.getNodeName())) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class CloudSolrServerTest extends AbstractFullDistribZkTestBase {
|
||||||
public CloudSolrServerTest() {
|
public CloudSolrServerTest() {
|
||||||
super();
|
super();
|
||||||
sliceCount = 2;
|
sliceCount = 2;
|
||||||
shardCount = 6;
|
shardCount = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue