mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-10-01 14:41:19 +00:00
SEARCH-98: Parameterizing the Jetty container creation.
This commit is contained in:
@@ -8,10 +8,6 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -71,11 +67,7 @@ import org.apache.solr.util.RefCounted;
|
|||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.rules.ExternalResource;
|
import org.junit.rules.ExternalResource;
|
||||||
import org.junit.rules.TestRule;
|
|
||||||
import org.junit.runner.Description;
|
|
||||||
import org.junit.runners.model.Statement;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -131,7 +123,7 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JettySolrRunner controlJetty;
|
protected Map<String, JettySolrRunner> jettyContainers = new HashMap<>();
|
||||||
protected List<SolrClient> clients = new ArrayList<>();
|
protected List<SolrClient> clients = new ArrayList<>();
|
||||||
protected List<JettySolrRunner> jettys = new ArrayList<>();
|
protected List<JettySolrRunner> jettys = new ArrayList<>();
|
||||||
|
|
||||||
@@ -252,7 +244,7 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
public void waitForDocCountAllCores(Query query, int count, long waitMillis) throws Exception {
|
public void waitForDocCountAllCores(Query query, int count, long waitMillis) throws Exception {
|
||||||
ArrayList<SolrCore> cores = new ArrayList();
|
ArrayList<SolrCore> cores = new ArrayList();
|
||||||
try {
|
try {
|
||||||
cores.add(controlJetty.getCoreContainer().getCore(DEFAULT_TEST_CORENAME));
|
cores.add(jettyContainers.get(DEFAULT_TEST_CORENAME).getCoreContainer().getCore(DEFAULT_TEST_CORENAME));
|
||||||
for (JettySolrRunner jettySolrRunner : jettys) {
|
for (JettySolrRunner jettySolrRunner : jettys) {
|
||||||
cores.add(jettySolrRunner.getCoreContainer().getCore(DEFAULT_TEST_CORENAME));
|
cores.add(jettySolrRunner.getCoreContainer().getCore(DEFAULT_TEST_CORENAME));
|
||||||
}
|
}
|
||||||
@@ -274,7 +266,7 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
|
|
||||||
SolrCore controlCore = null;
|
SolrCore controlCore = null;
|
||||||
try {
|
try {
|
||||||
controlCore = controlJetty.getCoreContainer().getCore(DEFAULT_TEST_CORENAME);
|
controlCore = jettyContainers.get(DEFAULT_TEST_CORENAME).getCoreContainer().getCore(DEFAULT_TEST_CORENAME);
|
||||||
waitForDocCountCore(controlCore, query, count, waitMillis, begin);
|
waitForDocCountCore(controlCore, query, count, waitMillis, begin);
|
||||||
} finally {
|
} finally {
|
||||||
controlCore.close();
|
controlCore.close();
|
||||||
@@ -423,14 +415,20 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createServers(int numShards) throws Exception
|
protected void createServers(String[] coreNames, int numShards) throws Exception
|
||||||
{
|
{
|
||||||
System.setProperty("configSetBaseDir", getSolrHome());
|
System.setProperty("configSetBaseDir", getSolrHome());
|
||||||
|
|
||||||
controlJetty = createJetty("Control");
|
for (int i = 0; i < coreNames.length; i++) {
|
||||||
String url = buildUrl(controlJetty.getLocalPort()) + "/" + DEFAULT_TEST_CORENAME;
|
JettySolrRunner jsr = createJetty(coreNames[i]);
|
||||||
log.info(url);
|
jettyContainers.put(coreNames[i], jsr);
|
||||||
controlClient = createNewSolrClient(url);
|
if (i == 0)
|
||||||
|
{
|
||||||
|
String url = buildUrl(jsr.getLocalPort()) + "/" + coreNames[i];
|
||||||
|
log.info(url);
|
||||||
|
controlClient = createNewSolrClient(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
shardsArr = new String[numShards];
|
shardsArr = new String[numShards];
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@@ -502,10 +500,10 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
protected void destroyServers() throws Exception
|
protected void destroyServers() throws Exception
|
||||||
{
|
{
|
||||||
List<String> solrHomes = new ArrayList<String>();
|
List<String> solrHomes = new ArrayList<String>();
|
||||||
if (controlJetty != null)
|
for (JettySolrRunner jetty : jettyContainers.values())
|
||||||
{
|
{
|
||||||
solrHomes.add(controlJetty.getSolrHome());
|
solrHomes.add(jetty.getSolrHome());
|
||||||
controlJetty.stop();
|
jetty.stop();
|
||||||
}
|
}
|
||||||
if (controlClient != null)
|
if (controlClient != null)
|
||||||
{
|
{
|
||||||
@@ -530,16 +528,7 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
|
|
||||||
clients.clear();
|
clients.clear();
|
||||||
jettys.clear();
|
jettys.clear();
|
||||||
}
|
jettyContainers.clear();
|
||||||
|
|
||||||
public JettySolrRunner createJetty(File solrHome, String dataDir) throws Exception
|
|
||||||
{
|
|
||||||
return createJetty(solrHome, dataDir, null, false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardId) throws Exception
|
|
||||||
{
|
|
||||||
return createJetty(solrHome, dataDir, shardId, false, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled,
|
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled,
|
||||||
@@ -1426,16 +1415,16 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
*/
|
*/
|
||||||
public class JettyServerRule extends ExternalResource {
|
public class JettyServerRule extends ExternalResource {
|
||||||
|
|
||||||
int numCores;
|
String[] coreNames;
|
||||||
int numShards;
|
int numShards;
|
||||||
|
|
||||||
public JettyServerRule(int numCores, int numShards) {
|
public JettyServerRule(int numShards, String ...coreNames) {
|
||||||
this.numCores = numCores;
|
this.coreNames = coreNames;
|
||||||
this.numShards = numShards;
|
this.numShards = numShards;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JettyServerRule(int numShards) {
|
public JettyServerRule(int numShards) {
|
||||||
this.numCores = 1;
|
coreNames = new String[]{DEFAULT_TEST_CORENAME};
|
||||||
this.numShards = numShards;
|
this.numShards = numShards;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1444,7 +1433,7 @@ public class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
|||||||
|
|
||||||
distribSetUp();
|
distribSetUp();
|
||||||
RandVal.uniqueValues = new HashSet(); // reset random values
|
RandVal.uniqueValues = new HashSet(); // reset random values
|
||||||
createServers(numShards);
|
createServers(coreNames, numShards);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user