mirror of https://github.com/apache/lucene.git
SOLR-5684: Shutdown SolrServer clients created in BasicDistributedZk2Test and BasicDistributedZkTest
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1563390 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2b7540c7a9
commit
13c01606a3
|
@ -319,6 +319,9 @@ Other Changes
|
|||
* SOLR-5633: HttpShardHandlerFactory should make its http client available to subclasses.
|
||||
(Ryan Ernst)
|
||||
|
||||
* SOLR-5684: Shutdown SolrServer clients created in BasicDistributedZk2Test and
|
||||
BasicDistributedZkTest. (Tomás Fernández Löbbe via shalin)
|
||||
|
||||
================== 4.6.1 ==================
|
||||
|
||||
Versions of Major Components
|
||||
|
|
|
@ -23,8 +23,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -34,7 +32,6 @@ import org.apache.solr.client.solrj.SolrServer;
|
|||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrServer;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrServer.RemoteSolrException;
|
||||
import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
|
@ -179,6 +176,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
|
|||
createCmd.setDataDir(getDataDir(dataDir.getAbsolutePath() + File.separator
|
||||
+ ONE_NODE_COLLECTION));
|
||||
server.request(createCmd);
|
||||
server.shutdown();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
|
@ -214,6 +212,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
|
|||
SolrQuery query = new SolrQuery("*:*");
|
||||
QueryResponse results = qclient.query(query);
|
||||
assertEquals(docs - 1, results.getResults().getNumFound());
|
||||
qclient.shutdown();
|
||||
|
||||
qclient = new HttpSolrServer(baseUrl + "/onenodecollection");
|
||||
results = qclient.query(query);
|
||||
|
@ -228,6 +227,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
|
|||
query.set("rows", 0);
|
||||
results = qclient.query(query);
|
||||
assertEquals(docs, results.getResults().getNumFound());
|
||||
qclient.shutdown();
|
||||
}
|
||||
|
||||
private long testUpdateAndDelete() throws Exception {
|
||||
|
@ -427,7 +427,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
|
|||
NamedList<Object> results = client.request(request );
|
||||
|
||||
checkForBackupSuccess(client, location);
|
||||
|
||||
|
||||
}
|
||||
private void checkForBackupSuccess(final HttpSolrServer client, File location)
|
||||
throws InterruptedException, IOException {
|
||||
|
|
|
@ -397,6 +397,8 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
fail("Expected SolrCore create to fail");
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
long timeout = System.currentTimeMillis() + 15000;
|
||||
|
@ -530,6 +532,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(120, TimeUnit.SECONDS);
|
||||
server.shutdown();
|
||||
|
||||
ChaosMonkey.stop(cloudJettys.get(0).jetty);
|
||||
printLayout();
|
||||
|
@ -614,7 +617,9 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
((HttpSolrServer) clients.get(clientIndex)).getBaseURL().length()
|
||||
- DEFAULT_COLLECTION.length() - 1);
|
||||
|
||||
createNewSolrServer("", baseUrl).request(request);
|
||||
SolrServer aClient = createNewSolrServer("", baseUrl);
|
||||
aClient.request(request);
|
||||
aClient.shutdown();
|
||||
} else {
|
||||
client.request(request);
|
||||
}
|
||||
|
@ -749,7 +754,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
NamedList uhandler = (NamedList) uhandlerCat.get("updateHandler");
|
||||
NamedList stats = (NamedList) uhandler.get("stats");
|
||||
Long commits = (Long) stats.get("commits");
|
||||
|
||||
server.shutdown();
|
||||
return commits;
|
||||
}
|
||||
|
||||
|
@ -758,7 +763,6 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
System.clearProperty("numShards");
|
||||
List<SolrServer> collectionClients = new ArrayList<SolrServer>();
|
||||
SolrServer client = clients.get(0);
|
||||
otherCollectionClients.put(oneInstanceCollection2, collectionClients);
|
||||
final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
|
||||
0,
|
||||
((HttpSolrServer) client).getBaseURL().length()
|
||||
|
@ -774,10 +778,10 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
pending.remove(future);
|
||||
}
|
||||
|
||||
SolrServer client1 = createNewSolrServer(oneInstanceCollection2 + "1", baseUrl);
|
||||
SolrServer client2 = createNewSolrServer(oneInstanceCollection2 + "2", baseUrl);
|
||||
SolrServer client3 = createNewSolrServer(oneInstanceCollection2 + "3", baseUrl);
|
||||
SolrServer client4 = createNewSolrServer(oneInstanceCollection2 + "4", baseUrl);
|
||||
SolrServer client1 = collectionClients.get(0);
|
||||
SolrServer client2 = collectionClients.get(1);
|
||||
SolrServer client3 = collectionClients.get(2);
|
||||
SolrServer client4 = collectionClients.get(3);
|
||||
|
||||
|
||||
// no one should be recovering
|
||||
|
@ -838,6 +842,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
String leader = props.getCoreUrl();
|
||||
|
||||
server.request(unloadCmd);
|
||||
server.shutdown();
|
||||
|
||||
int tries = 50;
|
||||
while (leader.equals(zkStateReader.getLeaderUrl(oneInstanceCollection2, "slice1", 10000))) {
|
||||
|
@ -847,6 +852,10 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
for (SolrServer aClient : collectionClients) {
|
||||
aClient.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void testSearchByCollectionName() throws SolrServerException {
|
||||
|
@ -863,6 +872,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
SolrQuery query = new SolrQuery("*:*");
|
||||
long oneDocs = client1.query(query).getResults().getNumFound();
|
||||
assertEquals(3, oneDocs);
|
||||
client1.shutdown();
|
||||
}
|
||||
|
||||
private void testUpdateByCollectionName() throws SolrServerException, IOException {
|
||||
|
@ -878,13 +888,13 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
// test hitting an update url
|
||||
SolrServer client1 = createNewSolrServer(oneInstanceCollection, baseUrl);
|
||||
client1.commit();
|
||||
client1.shutdown();
|
||||
}
|
||||
|
||||
private void testANewCollectionInOneInstance() throws Exception {
|
||||
log.info("### STARTING testANewCollectionInOneInstance");
|
||||
List<SolrServer> collectionClients = new ArrayList<SolrServer>();
|
||||
SolrServer client = clients.get(0);
|
||||
otherCollectionClients.put(oneInstanceCollection , collectionClients);
|
||||
final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
|
||||
0,
|
||||
((HttpSolrServer) client).getBaseURL().length()
|
||||
|
@ -900,12 +910,12 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
if (future == null) return;
|
||||
pending.remove(future);
|
||||
}
|
||||
|
||||
SolrServer client1 = createNewSolrServer(oneInstanceCollection + "1", baseUrl);
|
||||
SolrServer client2 = createNewSolrServer(oneInstanceCollection + "2", baseUrl);
|
||||
SolrServer client3 = createNewSolrServer(oneInstanceCollection + "3", baseUrl);
|
||||
SolrServer client4 = createNewSolrServer(oneInstanceCollection + "4", baseUrl);
|
||||
|
||||
|
||||
SolrServer client1 = collectionClients.get(0);
|
||||
SolrServer client2 = collectionClients.get(1);
|
||||
SolrServer client3 = collectionClients.get(2);
|
||||
SolrServer client4 = collectionClients.get(3);
|
||||
|
||||
waitForRecoveriesToFinish(oneInstanceCollection, getCommonCloudSolrServer().getZkStateReader(), false);
|
||||
assertAllActive(oneInstanceCollection, getCommonCloudSolrServer().getZkStateReader());
|
||||
|
||||
|
@ -932,6 +942,9 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
// System.out.println("All Docs:" + allDocs);
|
||||
|
||||
assertEquals(3, allDocs);
|
||||
for(SolrServer newCollectionClient:collectionClients) {
|
||||
newCollectionClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void createCollection(String collection,
|
||||
|
@ -983,7 +996,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
pending.add(completionService.submit(call));
|
||||
|
||||
|
||||
collectionClients.add(createNewSolrServer(collection, baseUrl));
|
||||
collectionClients.add(createNewSolrServer(collection + num, baseUrl));
|
||||
}
|
||||
|
||||
private void testMultipleCollections() throws Exception {
|
||||
|
@ -1170,6 +1183,17 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
if (commondCloudSolrServer != null) {
|
||||
commondCloudSolrServer.shutdown();
|
||||
}
|
||||
if (otherCollectionClients != null) {
|
||||
for (List<SolrServer> clientList : otherCollectionClients.values()) {
|
||||
for (SolrServer client : clientList) {
|
||||
client.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
otherCollectionClients = null;
|
||||
List<Runnable> tasks = executor.shutdownNow();
|
||||
assertTrue(tasks.isEmpty());
|
||||
|
||||
System.clearProperty("numShards");
|
||||
System.clearProperty("zkHost");
|
||||
System.clearProperty("solr.xml.persist");
|
||||
|
|
Loading…
Reference in New Issue