diff --git a/README.md b/README.md
index 0b78fd2e7..95ab30356 100644
--- a/README.md
+++ b/README.md
@@ -40,4 +40,4 @@ More details are available at [search-services](/search-services) folder.
**Following resources will not be available for Community users**
-More details are available at [insight-engine](/insight-engine) folder.
+More details are available at [insight-engine](/insight-engine) folder.
\ No newline at end of file
diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml
index e14adef45..084518ad3 100644
--- a/e2e-test/pom.xml
+++ b/e2e-test/pom.xml
@@ -11,9 +11,9 @@
Search Analytics E2E TestsTest Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share
- 1.20
+ 1.251.11
- 3.0.16
+ 3.0.173.2.0src/test/resources/SearchSuite.xml
diff --git a/search-services/README.md b/search-services/README.md
index f44e980ca..0c82e56d1 100644
--- a/search-services/README.md
+++ b/search-services/README.md
@@ -338,6 +338,22 @@ This Docker Image is available at Alfresco Docker Hub:
To use the public image instead of the local one (`searchservices:develop`) just use `alfresco/alfresco-search-services:1.3.x.x` labels.
+## Docker Master-Slave setup
+### Enable Search Slave Replica config
+
+To enable slave node specify environment value `REPLICATION_TYPE=slave`, by default Master config is enabled and slave is disabled.
+
+During deployment time whenever Search Services or Insight Engine image starts, it will execute the script [search_config_setup.sh](/packaging/src/docker) which will configure the slave config setup based on the value specified in the script.
+
+To run the docker image:
+
+```bash
+$ docker run -p 8984:8983 -e REPLICATION_TYPE=slave -e ALFRESCO_SECURE_COMMS=none -e SOLR_CREATE_ALFRESCO_DEFAULTS=alfresco,archive searchservices:develop
+```
+Solr-slave End point: [http://localhost:8984/solr](http://localhost:8984/solr)
+
+To generate your own Docker-compose file please follow [generator-alfresco-docker-compose](../e2e-test/generator-alfresco-docker-compose/README.md)
+
### Use Alfresco Search Services Docker Image with Docker Compose
Sample configuration in a Docker Compose file using **Plain HTTP** protocol to communicate with Alfresco Repository.
diff --git a/search-services/alfresco-search/pom.xml b/search-services/alfresco-search/pom.xml
index a348e4fe5..34d4aed4c 100644
--- a/search-services/alfresco-search/pom.xml
+++ b/search-services/alfresco-search/pom.xml
@@ -158,7 +158,7 @@
org.mockitomockito-core
- 3.2.0
+ 3.2.4test
diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/content/SolrContentStore.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/content/SolrContentStore.java
index bacb1d183..f08dcf288 100644
--- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/content/SolrContentStore.java
+++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/content/SolrContentStore.java
@@ -43,6 +43,7 @@ import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -257,7 +258,9 @@ public final class SolrContentStore implements Closeable, AccessMode
wr.write(Long.toString(version));
wr.close();
- tmpFile.renameTo(new File(root, ".version"));
+ // file.renameTo(..) does not work on windows. Use Files.move instead.
+ Files.move(tmpFile.toPath(), new File(root, ".version").toPath(), StandardCopyOption.REPLACE_EXISTING);
+
}
catch (IOException exception)
{
diff --git a/search-services/alfresco-search/src/main/java/org/alfresco/solr/handler/AlfrescoIndexFetcher.java b/search-services/alfresco-search/src/main/java/org/alfresco/solr/handler/AlfrescoIndexFetcher.java
index e9546a2b0..536ce0354 100644
--- a/search-services/alfresco-search/src/main/java/org/alfresco/solr/handler/AlfrescoIndexFetcher.java
+++ b/search-services/alfresco-search/src/main/java/org/alfresco/solr/handler/AlfrescoIndexFetcher.java
@@ -37,6 +37,7 @@ package org.alfresco.solr.handler;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import org.alfresco.solr.content.SolrContentStore;
+import org.apache.commons.io.FilenameUtils;
import org.apache.http.client.HttpClient;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.IndexCommit;
@@ -188,6 +189,13 @@ class AlfrescoIndexFetcher
private final Map confFileInfoCache = new HashMap<>();
private volatile Date replicationStartTimeStamp;
private RTimer replicationTimer;
+
+ /**
+ * The map contains the following fields:
+ * NAME : String -> file name(with path for contentstore files)
+ * SIZE : long -> file size
+ * CHECKSUM : long -> checksum
+ */
private volatile List
- *
*/
@BeforeClass
public static void setUpSolrTestProperties()
{
+ SOLR_RANDOM_SUPPLIER = new RandomSupplier();
System.setProperty("alfresco.test", "true");
System.setProperty("solr.tests.maxIndexingThreads", "10");
System.setProperty("solr.tests.ramBufferSizeMB", "1024");
}
- @Before
- public void setupPerTest()
- {
- this.solrRandomSupplier = new RandomSupplier();
- }
-
-
- public static String[] fieldNames = new String[]
- { "n_ti1", "n_f1", "n_tf1", "n_d1", "n_td1", "n_l1", "n_tl1", "n_dt1", "n_tdt1" };
-
+ public static final String[] FIELD_NAMES = new String[] { "n_ti1", "n_f1", "n_tf1", "n_d1", "n_td1", "n_l1", "n_tl1", "n_dt1", "n_tdt1" };
protected static String[] getFieldNames()
{
- return fieldNames;
+ return FIELD_NAMES;
}
- protected void putHandleDefaults() {
- solrComparator.putHandleDefaults();
+ protected static void putHandleDefaults()
+ {
+ SOLR_RESPONSE_COMPARATOR.putHandleDefaults();
}
/**
@@ -147,8 +139,6 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
* @param query - query to execute
* @param count - min number of results each shard must satisfy
* @param waitMillis - total ms to wait
- * @return
- * @throws Exception
*/
public static boolean checkMinCountPerShard(Query query, int count, long waitMillis) throws SolrServerException,IOException
{
@@ -160,7 +150,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
for (SolrClient singleShard : shardedClients)
{
allShardCompliant = false;
- int totalHits = 0;
+ int totalHits;
int cycles = 1;
while ((new Date()).getTime() < timeout && (!allShardCompliant))
{
@@ -172,11 +162,11 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
}
try
{
- Thread.sleep((long) (500 * cycles++));
+ Thread.sleep(500 * cycles++);
}
catch (InterruptedException e)
{
- continue;
+ // Ignore
}
}
}
@@ -205,11 +195,6 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
/**
* Waits until all cores (including shards) reach a count.
- *
- * @param query
- * @param count
- * @param waitMillis
- * @throws Exception
*/
public static void waitForDocCountAllCores(Query query, int count, long waitMillis) throws Exception
{
@@ -230,12 +215,9 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
/**
* Delele by query on all Clients
- *
- * @param q
- * @throws Exception
*/
- public static void deleteByQueryAllClients(String q) throws Exception {
-
+ public static void deleteByQueryAllClients(String q) throws Exception
+ {
List clients = getStandaloneAndShardedClients();
for (SolrClient client : clients) {
@@ -245,14 +227,11 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
/**
* Gets the Default test client.
- *
- * @return
*/
protected static SolrClient getDefaultTestClient()
{
return solrCollectionNameToStandaloneClient.get(DEFAULT_TEST_CORENAME);
}
-
protected static List getShardedClients()
{
@@ -266,7 +245,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
*/
public static List getStandaloneAndShardedClients()
{
- List clients = new ArrayList();
+ List clients = new ArrayList<>();
clients.addAll(solrCollectionNameToStandaloneClient.values());
clients.addAll(clientShards);
return clients;
@@ -275,17 +254,11 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
public static List getStandaloneClients()
{
- List clients = new ArrayList();
- clients.addAll(solrCollectionNameToStandaloneClient.values());
- return clients;
+ return new ArrayList<>(solrCollectionNameToStandaloneClient.values());
}
/**
* Waits for the doc count on the first core available, then checks all the Shards match.
- * @param query
- * @param count
- * @param waitMillis
- * @throws Exception
*/
public static void waitForDocCount(Query query, int count, long waitMillis) throws Exception
{
@@ -332,7 +305,8 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
return escapedField + ":" + value + " ";
}
- protected static String escapeQueryChars(String query) {
+ protected static String escapeQueryChars(String query)
+ {
return query.replaceAll("\\:", "\\\\:")
.replaceAll("\\{", "\\\\{")
.replaceAll("\\}", "\\\\}");
@@ -341,7 +315,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
public static SolrQuery luceneToSolrQuery(Query query)
{
String[] terms = query.toString().split(" ");
- String escapedQuery = new String();
+ String escapedQuery = "";
for (String t : terms)
{
escapedQuery += escapeQueryClause(t);
@@ -366,8 +340,10 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
waitForShardsCount(solrQuery, count, waitMillis, start);
}
- protected static void injectDocToShards(long txnId, long aclId, long dbId, String owner) throws Exception {
- for(SolrClient clientShard : clientShards) {
+ protected static void injectDocToShards(long txnId, long aclId, long dbId, String owner) throws Exception
+ {
+ for(SolrClient clientShard : clientShards)
+ {
SolrInputDocument doc = new SolrInputDocument();
String id = AlfrescoSolrDataModel.getNodeDocumentId(AlfrescoSolrDataModel.DEFAULT_TENANT, aclId, dbId);
doc.addField(FIELD_SOLR4_ID, id);
@@ -383,21 +359,20 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
/**
* Gets the cores for the jetty instances
- * @return
*/
protected static List getJettyCores(Collection runners)
{
- List cores = new ArrayList();
+ List cores = new ArrayList<>();
for (JettySolrRunner jettySolrRunner : runners)
{
- jettySolrRunner.getCoreContainer().getCores().forEach(aCore -> cores.add(aCore));
+ cores.addAll(jettySolrRunner.getCoreContainer().getCores());
}
return cores;
}
protected static List getAdminHandlers(Collection runners)
{
- List coreAdminHandlers = new ArrayList();
+ List coreAdminHandlers = new ArrayList<>();
for (JettySolrRunner jettySolrRunner : runners)
{
CoreContainer coreContainer = jettySolrRunner.getCoreContainer();
@@ -418,32 +393,27 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
List clients = getShardedClients();
SolrQuery query = luceneToSolrQuery(new TermQuery(new Term(FIELD_DOC_TYPE, SolrInformationServer.DOC_TYPE_NODE)));
StringBuilder error = new StringBuilder();
- for (int i = 0; i < clients.size(); ++i)
+ for (SolrClient client : clients)
{
- SolrClient client = clients.get(i);
-
-
QueryResponse response = client.query(query);
int totalHits = (int) response.getResults().getNumFound();
- if(totalHits > 0)
+ if (totalHits > 0)
{
shardHit++;
}
- if(totalHits < count)
+
+ if (totalHits < count)
{
- if (ignoreZero && totalHits == 0)
- {
- log.info(client+": have zero hits ");
- }
- else
- {
- error.append(" "+client+": ");
- error.append("Expected nodes per shard greater than "+count+" found "+totalHits+" : "+query.toString());
+ if (ignoreZero && totalHits == 0) {
+ log.info(client + ": have zero hits ");
+ } else {
+ error.append(" " + client + ": ");
+ error.append("Expected nodes per shard greater than " + count + " found " + totalHits + " : " + query.toString());
}
}
- log.info(client+": Hits "+totalHits);
+ log.info(client + ": Hits " + totalHits);
}
@@ -560,7 +530,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
protected String getShardsString()
{
- Random r = solrRandomSupplier.getRandomGenerator();
+ Random r = SOLR_RANDOM_SUPPLIER.getRandomGenerator();
if (deadServers == null)
return shards;
@@ -610,7 +580,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
protected static SolrInputDocument addRandFields(SolrInputDocument sdoc)
{
- addFields(sdoc, solrRandomSupplier.getRandFields(getFieldNames(), solrRandomSupplier.getRandValues()));
+ addFields(sdoc, SOLR_RANDOM_SUPPLIER.getRandFields(getFieldNames(), SOLR_RANDOM_SUPPLIER.getRandValues()));
return sdoc;
}
@@ -662,7 +632,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
{
UpdateResponse controlRsp = add(client1, params, sdocs);
UpdateResponse specificRsp = add(client2, params, sdocs);
- solrComparator.compareSolrResponses(specificRsp, controlRsp);
+ SOLR_RESPONSE_COMPARATOR.compareSolrResponses(specificRsp, controlRsp);
return specificRsp;
}
@@ -724,9 +694,6 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
/**
* * Commits to the specified client, and optionally all shards
- * @param client
- * @param andShards
- * @throws Exception
*/
protected static void commit(SolrClient client, boolean andShards) throws Exception
{
@@ -743,7 +710,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
protected static QueryResponse queryRandomShard(ModifiableSolrParams params) throws SolrServerException, IOException
{
- Random r = solrRandomSupplier.getRandomGenerator();
+ Random r = SOLR_RANDOM_SUPPLIER.getRandomGenerator();
int which = r.nextInt(clientShards.size());
SolrClient client = clientShards.get(which);
QueryResponse rsp = client.query(params);
@@ -755,13 +722,13 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
params.set("distrib", "false");
QueryRequest request = getAlfrescoRequest(json, params);
QueryResponse controlRsp = request.process(solrClient);
- solrComparator.validateResponse(controlRsp);
+ SOLR_RESPONSE_COMPARATOR.validateResponse(controlRsp);
if (andShards)
{
params.remove("distrib");
setDistributedParams(params);
QueryResponse rsp = queryRandomShard(json, params);
- solrComparator.compareResponses(rsp, controlRsp);
+ SOLR_RESPONSE_COMPARATOR.compareResponses(rsp, controlRsp);
return rsp;
}
else
@@ -772,7 +739,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
protected static QueryResponse queryRandomShard(String json, SolrParams params) throws SolrServerException, IOException
{
- Random r = solrRandomSupplier.getRandomGenerator();
+ Random r = SOLR_RANDOM_SUPPLIER.getRandomGenerator();
int which = r.nextInt(clientShards.size());
SolrClient client = clientShards.get(which);
QueryRequest request = getAlfrescoRequest(json, params);
@@ -791,13 +758,13 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
*/
protected QueryResponse query(SolrClient solrClient, boolean setDistribParams, SolrParams p) throws Exception
{
- Random r = solrRandomSupplier.getRandomGenerator();
+ Random r = SOLR_RANDOM_SUPPLIER.getRandomGenerator();
final ModifiableSolrParams params = new ModifiableSolrParams(p);
// TODO: look into why passing true causes fails
params.set("distrib", "false");
final QueryResponse controlRsp = solrClient.query(params);
- solrComparator.validateResponse(controlRsp);
+ SOLR_RESPONSE_COMPARATOR.validateResponse(controlRsp);
params.remove("distrib");
if (setDistribParams)
@@ -805,7 +772,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
QueryResponse rsp = queryRandomShard(params);
- solrComparator.compareResponses(rsp, controlRsp);
+ SOLR_RESPONSE_COMPARATOR.compareResponses(rsp, controlRsp);
if (stress > 0)
{
@@ -827,7 +794,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
QueryResponse rsp = client.query(new ModifiableSolrParams(params));
if (verifyStress)
{
- solrComparator.compareResponses(rsp, controlRsp);
+ SOLR_RESPONSE_COMPARATOR.compareResponses(rsp, controlRsp);
}
} catch (SolrServerException | IOException e)
{
@@ -865,7 +832,7 @@ public abstract class AbstractAlfrescoDistributedIT extends SolrITInitializer
first = rsp;
} else
{
- solrComparator.compareResponses(first, rsp);
+ SOLR_RESPONSE_COMPARATOR.compareResponses(first, rsp);
}
}
diff --git a/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrITInitializer.java b/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrITInitializer.java
index b06df1a09..3bc5bd666 100644
--- a/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrITInitializer.java
+++ b/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrITInitializer.java
@@ -91,8 +91,8 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
//Standalone Tests
protected static SolrCore defaultCore;
- protected static final int clientConnectionTimeout = DEFAULT_CONNECTION_TIMEOUT;;
- protected static final int clientSoTimeout = 90000;;
+ protected static final int clientConnectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
+ protected static final int clientSoTimeout = 90000;
protected static final String id = "id";
@@ -129,21 +129,22 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
jettyContainers = new HashMap<>();
nodeCnt = new AtomicInteger(0);
- String serverName = testClassName;
- currentTestName = serverName;
+ currentTestName = testClassName;
String[] coreNames = new String[]{DEFAULT_TEST_CORENAME};
- distribSetUp(serverName);
- RandomSupplier.RandVal.uniqueValues = new HashSet(); // reset random values
- createServers(serverName, coreNames, numShards,solrcoreProperties);
- System.setProperty("solr.solr.home", testDir.toPath().resolve(serverName).toString());
+ distribSetUp(testClassName);
+ RandomSupplier.RandVal.uniqueValues = new HashSet<>(); // reset random values
+ createServers(testClassName, coreNames, numShards,solrcoreProperties);
+ System.setProperty("solr.solr.home", testDir.toPath().resolve(testClassName).toString());
}
private static Properties addExplicitShardingProperty(Properties solrcoreProperties)
{
- if(solrcoreProperties == null){
+ if(solrcoreProperties == null)
+ {
solrcoreProperties = new Properties();
}
+
if(solrcoreProperties.getProperty("shard.method")==null)
{
solrcoreProperties.put("shard.method", "EXPLICIT_ID");
@@ -151,7 +152,8 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
return solrcoreProperties;
}
- public static void initSingleSolrServer(String testClassName, Properties solrcoreProperties) throws Throwable {
+ public static void initSingleSolrServer(String testClassName, Properties solrcoreProperties) throws Throwable
+ {
initSolrServers(0,testClassName,solrcoreProperties);
JettySolrRunner jsr = jettyContainers.get(testClassName);
@@ -163,7 +165,8 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
{
int i = 0;
extras = new String[solrcoreProperties.size()*2];
- for (Map.Entry