From 354ac5cfe3bc9620a5c81242914c98dd29354bd8 Mon Sep 17 00:00:00 2001
From: "dependabot-preview[bot]"
<27856297+dependabot-preview[bot]@users.noreply.github.com>
Date: Mon, 18 Nov 2019 22:13:38 +0000
Subject: [PATCH 001/109] Bump alfresco-data-model from 8.53 to 8.54 in
/search-services
Bumps [alfresco-data-model](https://github.com/Alfresco/alfresco-data-model) from 8.53 to 8.54.
- [Release notes](https://github.com/Alfresco/alfresco-data-model/releases)
- [Commits](https://github.com/Alfresco/alfresco-data-model/compare/8.53...8.54)
Signed-off-by: dependabot-preview[bot]
---
search-services/alfresco-solrclient-lib/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/search-services/alfresco-solrclient-lib/pom.xml b/search-services/alfresco-solrclient-lib/pom.xml
index 5c75cb1e0..381855471 100644
--- a/search-services/alfresco-solrclient-lib/pom.xml
+++ b/search-services/alfresco-solrclient-lib/pom.xml
@@ -22,7 +22,7 @@
- 8.53
+ 8.54
2.10.1
From dbfbf2f9e0e4348ac78bc6824d793032cf7fba78 Mon Sep 17 00:00:00 2001
From: agazzarini
Date: Wed, 20 Nov 2019 10:44:04 +0100
Subject: [PATCH 002/109] [ SEARCH-1861 ] Remove ignored test
---
.../alfresco/solr/tracker/AclTrackerTest.java | 282 ------------------
1 file changed, 282 deletions(-)
delete mode 100644 search-services/alfresco-search/src/test/java/org/alfresco/solr/tracker/AclTrackerTest.java
diff --git a/search-services/alfresco-search/src/test/java/org/alfresco/solr/tracker/AclTrackerTest.java b/search-services/alfresco-search/src/test/java/org/alfresco/solr/tracker/AclTrackerTest.java
deleted file mode 100644
index 1e182dc39..000000000
--- a/search-services/alfresco-search/src/test/java/org/alfresco/solr/tracker/AclTrackerTest.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2005-2014 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.solr.tracker;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import org.alfresco.solr.IndexTrackingShutdownException;
-import org.alfresco.solr.InformationServer;
-import org.alfresco.solr.TrackerState;
-import org.alfresco.solr.client.AclChangeSet;
-import org.alfresco.solr.client.AclChangeSets;
-import org.alfresco.solr.client.SOLRAPIClient;
-import org.apache.commons.lang.reflect.FieldUtils;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-/**
- * Unit tests for the {@link AclTracker} class.
- *
- * @author Matt Ward
- */
-@RunWith(MockitoJUnitRunner.class)
-public class AclTrackerTest
-{
- private static final Object CUSTOM_ALFRESCO_VERSION = "99.9.9";
- // The class under test
- private AclTracker tracker;
- private @Mock SOLRAPIClient client;
- private @Mock InformationServer informationServer;
- private TrackerState trackerState;
-
- @Before
- public void setUp() throws Exception
- {
- trackerState = new TrackerState();
- trackerState.setRunning(false); // Nothing would happen if it were already running.
- Properties props = createProperties();
- // Spy in order to stub some methods and verify others. Note: non-stubbed methods go to the real class.
- tracker = spy(new AclTracker(props, client, "core-name", informationServer));
- }
-
- private Properties createProperties()
- {
- Properties props = new Properties();
- props.put("alfresco.stores", "workspace://SpacesStore");
- props.put("alfresco.version", CUSTOM_ALFRESCO_VERSION);
- return props;
- }
-
- protected void testTrackChangesRan()
- {
- when(tracker.getTrackerState()).thenReturn(trackerState);
-
- tracker.track();
-
- assertFalse(trackerState.isRunning());
- assertFalse(trackerState.isCheck());
- }
-
-
- // High level test of doTrack() workflow.
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void checkTrackingOperaionsPerformed() throws Throwable
- {
- testTrackChangesRan();
-
- verify(tracker).purgeAclChangeSets();
- verify(tracker).purgeAcls();
-
- verify(tracker).reindexAclChangeSets();
- verify(tracker).reindexAcls();
-
- verify(tracker).indexAclChangeSets();
- verify(tracker).indexAcls();
-
- verify(tracker).trackRepository();
- }
-
-
- // Tests the purgeAclChangeSets() call made in AclTracker.doTrack()
- // TODO: the other operations in doTrack().
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void checkTrackingWhenAclChangeSetsToPurge() throws IllegalAccessException, IOException
- {
- @SuppressWarnings("unchecked")
- ConcurrentLinkedQueue aclChangeSetsToPurge = (ConcurrentLinkedQueue)
- FieldUtils.readField(tracker, "aclChangeSetsToPurge", true);
- aclChangeSetsToPurge.add(101L);
- aclChangeSetsToPurge.add(102L);
- aclChangeSetsToPurge.add(103L);
-
- // Invoke the behaviour we're testing
- testTrackChangesRan();
-
- // aclChangeSetsToPurge
- verify(informationServer).deleteByAclChangeSetId(101L);
- verify(informationServer).deleteByAclChangeSetId(102L);
- verify(informationServer).deleteByAclChangeSetId(103L);
-
- // TODO: verify checkShutdown
- verify(informationServer).commit();
- }
-
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void checkTrackingWhenAclsToPurge() throws IllegalAccessException, IOException
- {
- @SuppressWarnings("unchecked")
- ConcurrentLinkedQueue aclsToPurge = (ConcurrentLinkedQueue)
- FieldUtils.readField(tracker, "aclsToPurge", true);
- aclsToPurge.add(201L);
- aclsToPurge.add(202L);
- aclsToPurge.add(203L);
-
- // Invoke the behaviour we're testing
- testTrackChangesRan();
-
- // aclsToPurge
- verify(informationServer).deleteByAclId(201L);
- verify(informationServer).deleteByAclId(202L);
- verify(informationServer).deleteByAclId(203L);
-
- // TODO: verify checkShutdown
- verify(informationServer).commit();
- }
-
- // TODO: Commented out, approach not working
- // Rethink or finish later.
- /*@Test
- public void checkTrackingWhenAclChangeSetsToReindex() throws IllegalAccessException, IOException, AuthenticationException, JSONException
- {
- @SuppressWarnings("unchecked")
- ConcurrentLinkedQueue aclChangeSetsToReindex = (ConcurrentLinkedQueue)
- FieldUtils.readField(tracker, "aclChangeSetsToReindex", true);
- aclChangeSetsToReindex.add(301L);
- aclChangeSetsToReindex.add(302L);
- aclChangeSetsToReindex.add(303L);
-
- // tracker will loop through list of ACLs to reindex, and get changesets for each changeset ID.
- when(client.getAclChangeSets(null, 201L, null, 202L, 1)).thenReturn(mockChangeSets(201L));
- when(client.getAclChangeSets(null, 202L, null, 203L, 1)).thenReturn(mockChangeSets(202L));
- when(client.getAclChangeSets(null, 203L, null, 204L, 1)).thenReturn(mockChangeSets(203L));
-
- when(client.getAcls(Collections.singletonList(new AclChangeSet(201L, 0L, 1)), null, Integer.MAX_VALUE)).thenReturn(Collections.singletonList(new Acl(201L, 0L)));
- when(client.getAcls(Collections.singletonList(new AclChangeSet(202L, 0L, 1)), null, Integer.MAX_VALUE)).thenReturn(Collections.singletonList(new Acl(202L, 0L)));
- when(client.getAcls(Collections.singletonList(new AclChangeSet(203L, 0L, 1)), null, Integer.MAX_VALUE)).thenReturn(Collections.singletonList(new Acl(203L, 0L)));
-
- // TODO: ...more...
-
- // Invoke the behaviour we're testing
- testTrackChangesRan();
-
- verify(informationServer).deleteByAclChangeSetId(301L);
- verify(informationServer).deleteByAclChangeSetId(302L);
- verify(informationServer).deleteByAclChangeSetId(303L);
-
- // TODO: verify checkShutdown
- verify(informationServer).commit();
- }*/
-
- private AclChangeSets mockChangeSets(long id)
- {
- List changeSets = Collections.singletonList(new AclChangeSet(id, 0L, 1));
- AclChangeSets acs = mock(AclChangeSets.class);
- when(acs.getAclChangeSets()).thenReturn(changeSets);
- return acs;
- }
-
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void trackingAbortsWhenAlreadyRunning() throws Throwable
- {
- trackerState.setRunning(true);
- // Prove running state, before attempt to track()
- assertTrue(trackerState.isRunning());
-
- FieldUtils.writeField(tracker, "state", trackerState, true);
- tracker.track();
-
- // Still running - these values are unaffected.
- assertTrue(trackerState.isRunning());
- assertFalse(trackerState.isCheck());
-
- // Prove doTrack() was not called
- verify(tracker, never()).doTrack();
- }
-
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void willRollbackOnThrowableDuringTracking() throws Throwable
- {
- doThrow(new RuntimeException("Simulated problem during tracking")).when(tracker).doTrack();
-
- testTrackChangesRan();
-
- verify(informationServer).rollback();
- }
-
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void willRollbackOnIndexTrackingShutdownException() throws Throwable
- {
- doThrow(new IndexTrackingShutdownException()).when(tracker).doTrack();
-
- testTrackChangesRan();
-
- verify(informationServer).rollback();
- }
-
- @Ignore("Not yet implemented.")
- @Test
- public void canCheckIndex()
- {
- // TODO
-// tracker.checkIndex(fromTx, toTx, fromAclTx, toAclTx, fromTime, toTime);
- }
-
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void canGetAlfrescoVersion()
- {
- // Check we're testing something useful
- assertNotNull(CUSTOM_ALFRESCO_VERSION);
- // Check alfresco version retrieved from properties
- assertEquals(CUSTOM_ALFRESCO_VERSION, tracker.getAlfrescoVersion());
- }
-
-
- @Test
- @Ignore("Superseded by AlfrescoSolrTrackerTest")
- public void canClose() throws IllegalAccessException
- {
- ThreadHandler threadHandler = (ThreadHandler) FieldUtils.readField(tracker, "threadHandler", true);
- threadHandler = spy(threadHandler);
- FieldUtils.writeField(tracker, "threadHandler", threadHandler, true);
-
- tracker.shutdown();
-
- // AclTracker specific
- verify(threadHandler).shutDownThreadPool();
-
- // Applicable to all AbstractAclTracker
- verify(client).close();
- }
-}
From 2fbb28123f0e2364f323007766f1b51e40e81f92 Mon Sep 17 00:00:00 2001
From: agazzarini
Date: Wed, 20 Nov 2019 10:45:46 +0100
Subject: [PATCH 003/109] [ SEARCH-1861 ] Removed commented test method in
SolrInformationTest
---
.../solr/SolrInformationServerTest.java | 78 +------------------
1 file changed, 3 insertions(+), 75 deletions(-)
diff --git a/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrInformationServerTest.java b/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrInformationServerTest.java
index 69c910e7f..aeb59b41b 100644
--- a/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrInformationServerTest.java
+++ b/search-services/alfresco-search/src/test/java/org/alfresco/solr/SolrInformationServerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2014 Alfresco Software Limited.
+ * Copyright (C) 2005-2019 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -19,18 +19,15 @@
package org.alfresco.solr;
-import java.io.IOException;
import java.util.Properties;
import org.alfresco.solr.client.SOLRAPIClient;
import org.alfresco.solr.content.SolrContentStore;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrResourceLoader;
-import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.response.SolrQueryResponse;
@@ -43,8 +40,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -99,6 +94,7 @@ public class SolrInformationServerTest
request = infoServer.newSolrQueryRequest();
}
+ @SuppressWarnings("unchecked")
@Test
public void testGetStateOk()
{
@@ -124,6 +120,7 @@ public class SolrInformationServerTest
/**
* GetState returns null in case the given id doesn't correspond to an existing state document.
*/
+ @SuppressWarnings("unchecked")
@Test
public void testGetStateWithStateNotFound_returnsNull()
{
@@ -143,73 +140,4 @@ public class SolrInformationServerTest
assertNull(document);
}
-
- @Test
- public void testIndexAcl() throws IOException
- {
- /*
- // Source/expected data
- List aclReadersList = new ArrayList();
- aclReadersList.add(new AclReaders(101, Arrays.asList("r1", "r2", "r3"), Arrays.asList("d1", "d2"), 999,
- "example.com"));
- aclReadersList.add(new AclReaders(102, Arrays.asList("r4", "r5", "r6"), Arrays.asList("d3", "d4"), 999,
- "another.test"));
- aclReadersList.add(new AclReaders(103, Arrays.asList("GROUP_marketing", "simpleuser", "GROUP_EVERYONE",
- "ROLE_GUEST", "ROLE_ADMINISTRATOR", "ROLE_OWNER", "ROLE_RANDOM"), Arrays.asList(
- "GROUP_engineering", "justauser", "GROUP_EVERYONE", "ROLE_GUEST", "ROLE_ADMINISTRATOR",
- "ROLE_OWNER", "ROLE_RANDOM"), 999, "tenant.test"));
- aclReadersList.add(new AclReaders(104, Arrays.asList("GROUP_marketing", "simpleuser", "GROUP_EVERYONE",
- "ROLE_GUEST", "ROLE_ADMINISTRATOR", "ROLE_OWNER", "ROLE_RANDOM"), Arrays.asList(
- "GROUP_engineering", "justauser", "GROUP_EVERYONE", "ROLE_GUEST", "ROLE_ADMINISTRATOR",
- "ROLE_OWNER", "ROLE_RANDOM"), 999, "" Zero-length tenant == no mangling ));
-
- //final boolean willOverwrite = true;
-
- // Invoke the method under test
- //infoServer.indexAcl(aclReadersList, willOverwrite);
-
-
- // Capture the AddUpdateCommand instances for further analysis.
- //ArgumentCaptor cmdArg = ArgumentCaptor.forClass(AddUpdateCommand.class);
- // The processor processes as many add commands as there are items in the aclReaderList.
- //verify(processor, times(aclReadersList.size())).processAdd(cmdArg.capture());
-
- // Verify that the AddUpdateCommand is as expected.
- //List updates = cmdArg.getAllValues();
- //assertEquals("Wrong number of updates", aclReadersList.size(), updates.size());
- /*
- for (int docIndex = 0; docIndex < updates.size(); docIndex++)
- {
- AddUpdateCommand update = updates.get(docIndex);
- assertEquals("Overwrite flag was not correct value.", willOverwrite, update.overwrite);
- SolrInputDocument inputDoc = update.getSolrInputDocument();
- // Retrieve the original AclReaders object and compare with data in submitted SolrInputDocument
- final AclReaders sourceAclReaders = aclReadersList.get(docIndex);
- assertEquals(
- AlfrescoSolrDataModel.getTenantId(sourceAclReaders.getTenantDomain()) + "!"
- + NumericEncoder.encode(sourceAclReaders.getId()) + "!ACL",
- inputDoc.getFieldValue("id").toString());
- assertEquals("0", inputDoc.getFieldValue("_version_").toString());
- assertEquals(sourceAclReaders.getId(), inputDoc.getFieldValue(QueryConstants.FIELD_ACLID));
- assertEquals(sourceAclReaders.getAclChangeSetId(), inputDoc.getFieldValue(QueryConstants.FIELD_INACLTXID));
-
- if (sourceAclReaders.getId() == 103)
- {
- // Authorities *may* (e.g. GROUP, EVERYONE, GUEST) be mangled to include tenant information
- final Collection
- *
*/
@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 prop:solrcoreProperties.entrySet()) {
+ for (Map.Entry prop:solrcoreProperties.entrySet())
+ {
extras[i++] = "property."+prop.getKey();
extras[i++] = (String) prop.getValue();
}
@@ -185,7 +188,7 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
destroyServers();
distribTearDown();
- boolean keepTests = Boolean.valueOf(System.getProperty("keep.tests"));
+ boolean keepTests = Boolean.parseBoolean(System.getProperty("keep.tests"));
if (!keepTests) FileUtils.deleteDirectory(testDir);
}
catch (Exception e)
@@ -203,7 +206,7 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
return System.getProperty("user.dir") + "/target/test-classes/test-files";
}
- public static void distribSetUp(String serverName) throws Exception
+ public static void distribSetUp(String serverName)
{
SolrTestCaseJ4.resetExceptionIgnores(); // ignore anything with
// ignore_exception in it
@@ -213,7 +216,7 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
System.setProperty("solr.log.dir", testDir.toPath().resolve(serverName).toString());
}
- public static void distribTearDown() throws Exception
+ public static void distribTearDown()
{
System.clearProperty("solr.directoryFactory");
System.clearProperty("solr.log.dir");
@@ -230,8 +233,6 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
/**
* Creates a JettySolrRunner (if one didn't exist already). DOES NOT START IT.
- * @return
- * @throws Exception
*/
protected static JettySolrRunner createJetty(String jettyKey, boolean basicAuth) throws Exception
{
@@ -243,19 +244,13 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
{
Path jettySolrHome = testDir.toPath().resolve(jettyKey);
seedSolrHome(jettySolrHome);
- JettySolrRunner jetty = createJetty(jettySolrHome.toFile(), null, null, false, 0, getSchemaFile(), basicAuth);
- return jetty;
+ return createJetty(jettySolrHome.toFile(), null, null, false, 0, getSchemaFile(), basicAuth);
}
}
/**
* Adds the core config information to the jetty file system.
* Its best to call this before calling start() on Jetty
- * @param jettyKey
- * @param sourceConfigName
- * @param coreName
- * @param additionalProperties
- * @throws Exception
*/
protected static void addCoreToJetty(String jettyKey, String sourceConfigName, String coreName, Properties additionalProperties) throws Exception
{
@@ -289,17 +284,14 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
out.close();
in.close();
}
-
}
-
}
/**
* Starts jetty if its not already running
- * @param jsr
- * @throws Exception
*/
- protected static void startJetty(JettySolrRunner jsr) throws Exception {
+ protected static void startJetty(JettySolrRunner jsr) throws Exception
+ {
if (!jsr.isRunning())
{
jsr.start();
@@ -310,37 +302,40 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
{
boolean basicAuth = additionalProperties != null ? Boolean.parseBoolean(additionalProperties.getProperty("BasicAuth", "false")) : false;
-
JettySolrRunner jsr = createJetty(jettyKey, basicAuth);
jettyContainers.put(jettyKey, jsr);
Properties properties = new Properties();
- if(additionalProperties != null && additionalProperties.size() > 0) {
+ if(additionalProperties != null && additionalProperties.size() > 0)
+ {
properties.putAll(additionalProperties);
properties.remove("shard.method");
}
- for (int i = 0; i < coreNames.length; i++)
+ for (String coreName : coreNames)
{
- addCoreToJetty(jettyKey, coreNames[i], coreNames[i], properties);
+ addCoreToJetty(jettyKey, coreName, coreName, properties);
}
//Now start jetty
startJetty(jsr);
int jettyPort = jsr.getLocalPort();
- for (int i = 0; i < coreNames.length; i++)
+ for (String coreName : coreNames)
{
- String url = buildUrl(jettyPort) + "/" + coreNames[i];
+ String url = buildUrl(jettyPort) + "/" + coreName;
+
log.info(url);
- solrCollectionNameToStandaloneClient.put(coreNames[i], createNewSolrClient(url));
+
+ solrCollectionNameToStandaloneClient.put(coreName, createNewSolrClient(url));
}
shardsArr = new String[numShards];
StringBuilder sb = new StringBuilder();
- if (additionalProperties == null) {
+ if (additionalProperties == null)
+ {
additionalProperties = new Properties();
}
String[] ranges = {"0-100", "100-200", "200-300", "300-400"};
@@ -382,6 +377,7 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
solrHomes.add(jetty.getSolrHome());
jetty.stop();
}
+
for (SolrClient jClients : solrCollectionNameToStandaloneClient.values())
{
jClients.close();
@@ -409,25 +405,16 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
solrCollectionNameToStandaloneClient.clear();
}
- public static JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled, int port, String schemaOverride, boolean basicAuth) throws Exception
+ public static JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled, int port, String schemaOverride, boolean basicAuth)
{
return createJetty(solrHome, dataDir, shardList, sslEnabled, port, schemaOverride, useExplicitNodeNames, basicAuth);
}
/**
* Create a solr jetty server.
- *
- * @param solrHome
- * @param dataDir
- * @param shardList
- * @param port
- * @param schemaOverride
- * @param explicitCoreNodeName
- * @return
- * @throws Exception
*/
public static JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled, int port,
- String schemaOverride, boolean explicitCoreNodeName, boolean basicAuth) throws Exception
+ String schemaOverride, boolean explicitCoreNodeName, boolean basicAuth)
{
Properties props = new Properties();
if (schemaOverride != null)
@@ -443,20 +430,21 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
{
props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet()));
}
+
SSLConfig sslConfig = new SSLConfig(sslEnabled, false, null, null, null, null);
- JettyConfig config = null;
+ JettyConfig config;
- if(basicAuth) {
- System.out.println("###### adding basic auth ######");
+ if(basicAuth)
+ {
+ log.info("###### adding basic auth ######");
config = JettyConfig.builder().setContext("/solr").setPort(port).withFilter(BasicAuthFilter.class, "/sql/*").stopAtShutdown(true).withSSLConfig(sslConfig).build();
} else {
- System.out.println("###### no basic auth ######");
+ log.info("###### no basic auth ######");
config = JettyConfig.builder().setContext("/solr").setPort(port).stopAtShutdown(true).withSSLConfig(sslConfig).build();
}
- JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, config);
- return jetty;
+ return new JettySolrRunner(solrHome.getAbsolutePath(), props, config);
}
/**
@@ -510,11 +498,8 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
*/
protected static void seedSolrHome(Path jettyHome) throws IOException
{
- String solrxml = getSolrXml();
- if (solrxml != null)
- {
- FileUtils.copyFile(new File(getTestFilesHome(), solrxml), jettyHome.resolve(getSolrXml()).toFile());
- }
+ FileUtils.copyFile(new File(getTestFilesHome(), getSolrXml()), jettyHome.resolve(getSolrXml()).toFile());
+
//Add solr home conf folder with alfresco based configuration.
FileUtils.copyDirectory(new File(getTestFilesHome() + "/conf"), jettyHome.resolve("conf").toFile());
// Add alfresco data model def
@@ -547,36 +532,26 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
FileUtils.copyDirectory(coreSourceConfig.resolve("conf").toFile(), confDir.toFile());
}
- protected void setupJettySolrHome(String coreName, Path jettyHome) throws IOException
+ public static class BasicAuthFilter implements Filter
{
- seedSolrHome(jettyHome);
- Properties coreProperties = new Properties();
- coreProperties.setProperty("name", coreName);
- coreProperties.setProperty("shard", "${shard:}");
- coreProperties.setProperty("collection", "${collection:" + coreName + "}");
- coreProperties.setProperty("config", "${solrconfig:solrconfig.xml}");
- coreProperties.setProperty("schema", "${schema:schema.xml}");
- coreProperties.setProperty("coreNodeName", "${coreNodeName:}");
-
- writeCoreProperties(jettyHome.resolve("cores").resolve(coreName), coreProperties, coreName);
- }
-
- public static class BasicAuthFilter implements Filter {
-
- public BasicAuthFilter() {
+ public BasicAuthFilter()
+ {
}
- public void init(FilterConfig config) {
+ public void init(FilterConfig config)
+ {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
- throws IOException, ServletException {
+ throws IOException, ServletException
+ {
//Parse the basic auth filter
String auth = ((HttpServletRequest)request).getHeader("Authorization");
- if(auth != null) {
+ if(auth != null)
+ {
auth = auth.replace("Basic ", "");
byte[] bytes = Base64.getDecoder().decode(auth);
String decodedBytes = new String(bytes);
@@ -584,18 +559,24 @@ public abstract class SolrITInitializer extends SolrTestCaseJ4
String user = pair[0];
String password = pair[1];
//Just look for the hard coded user and password.
- if (user.equals("test") && password.equals("pass")) {
+ if (user.equals("test") && password.equals("pass"))
+ {
filterChain.doFilter(request, response);
- } else {
+ }
+ else
+ {
((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN);
}
- } else {
+ }
+ else
+ {
((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN);
}
}
- public void destroy() {
+ public void destroy()
+ {
}
}
-}
+}
\ No newline at end of file
From d650cf497d0e65098827a9c15e3b8bbeec112a12 Mon Sep 17 00:00:00 2001
From: sridharvellingiri
Date: Wed, 11 Dec 2019 17:40:59 +0000
Subject: [PATCH 045/109] SEARCH-2011 Updating Slave replica config setup
---
.../src/docker/6.x/docker-compose.yml | 25 +++++++++++
.../src/docker/search_config_setup.sh | 41 +++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/search-services/packaging/src/docker/6.x/docker-compose.yml b/search-services/packaging/src/docker/6.x/docker-compose.yml
index 1174827d3..ca4268e79 100644
--- a/search-services/packaging/src/docker/6.x/docker-compose.yml
+++ b/search-services/packaging/src/docker/6.x/docker-compose.yml
@@ -37,6 +37,10 @@ services:
search:
image: quay.io/alfresco/search-services:${SEARCH_TAG}
environment:
+ #Replication properties
+ - REPLICATION_TYPE=master
+ #- REPLICATION_AFTER=commit,startup- SOLR_ALFRESCO_HOST=alfresco
+ #- REPLICATION_CONFIG_FILES=schema.xml,stopwords.txt- SOLR_ALFRESCO_PORT=8080
#Solr needs to know how to register itself with Alfresco
- SOLR_ALFRESCO_HOST=alfresco
- SOLR_ALFRESCO_PORT=8080
@@ -51,6 +55,27 @@ services:
- ENABLE_SPELLCHECK=${SEARCH_ENABLE_SPELLCHECK}
ports:
- 8083:8983 #Browser port
+ #search_slave:
+ # image: quay.io/alfresco/search-services:${SEARCH_TAG}
+ # environment:
+ # #Replication properties
+ # - REPLICATION_TYPE=slave
+ # - REPLICATION_MASTER_HOST=search
+ # - REPLICATION_MASTER_PORT=8983
+ # #- REPLICATION_MASTER_PROTOCOL=http
+ # #- REPLICATION_CORE_NAME=alfresco
+ # #- REPLICATION_POLL_INTERVAL=00:00:60
+ # #Solr needs to know how to register itself with Alfresco
+ # - SOLR_ALFRESCO_HOST=alfresco
+ # - SOLR_ALFRESCO_PORT=8080
+ # #Alfresco needs to know how to call solr
+ # - SOLR_SOLR_HOST=search
+ # - SOLR_SOLR_PORT=8983
+ # #Create the default alfresco and archive cores
+ # - SOLR_CREATE_ALFRESCO_DEFAULTS=alfresco,archive
+ # ports:
+ # - 8084:8983 #Browser port
+
activemq:
image: alfresco/alfresco-activemq:5.15.6
ports:
diff --git a/search-services/packaging/src/docker/search_config_setup.sh b/search-services/packaging/src/docker/search_config_setup.sh
index 40ad069e1..090a4c648 100644
--- a/search-services/packaging/src/docker/search_config_setup.sh
+++ b/search-services/packaging/src/docker/search_config_setup.sh
@@ -1,6 +1,47 @@
#!/bin/bash
set -e
+SOLR_CONFIG_FILE=$PWD/solrhome/templates/rerank/conf/solrconfig.xml
+if [[ $REPLICATION_TYPE == "master" ]]; then
+
+ findStringMaster=''
+ replaceStringMaster="\n\t \n"
+ if [[ $REPLICATION_AFTER == "" ]]; then
+ REPLICATION_AFTER=commit
+ fi
+ for i in $(echo $REPLICATION_AFTER | sed "s/,/ /g")
+ do
+ replaceStringMaster+="\t\t"$i"<\/str> \n"
+ done
+ if [[ ! -z "$REPLICATION_CONFIG_FILES" ]]; then
+ replaceStringMaster+="\t\t$REPLICATION_CONFIG_FILES<\/str> \n"
+ fi
+ replaceStringMaster+="\t<\/lst>"
+ sed -i -e "s/$findStringMaster/$findStringMaster$replaceStringMaster/g" $SOLR_CONFIG_FILE
+fi
+if [[ $REPLICATION_TYPE == "slave" ]]; then
+ if [[ $REPLICATION_MASTER_PROTOCOL == "" ]]; then
+ REPLICATION_MASTER_PROTOCOL=http
+ fi
+ if [[ $REPLICATION_MASTER_HOST == "" ]]; then
+ REPLICATION_MASTER_HOST=localhost
+ fi
+ if [[ $REPLICATION_MASTER_PORT == "" ]]; then
+ REPLICATION_MASTER_PORT=8083
+ fi
+ if [[ $REPLICATION_CORE_NAME == "" ]]; then
+ REPLICATION_CORE_NAME=alfresco
+ fi
+ if [[ $REPLICATION_POLL_INTERVAL == "" ]]; then
+ REPLICATION_POLL_INTERVAL=00:00:30
+ fi
+ sed -i 's//\
+ \
+ '$REPLICATION_MASTER_PROTOCOL':\/\/'$REPLICATION_MASTER_HOST':'$REPLICATION_MASTER_PORT'\/solr\/'$REPLICATION_CORE_NAME'<\/str>\
+ '$REPLICATION_POLL_INTERVAL'<\/str>\
+ <\/lst>/g' $SOLR_CONFIG_FILE
+fi
+
SOLR_IN_FILE=$PWD/solr.in.sh
if [[ ! -z "$MAX_SOLR_RAM_PERCENTAGE" ]]; then
From 0fe58cb31fc2a145adaf8d35675d69040c35802b Mon Sep 17 00:00:00 2001
From: "dependabot-preview[bot]"
<27856297+dependabot-preview[bot]@users.noreply.github.com>
Date: Wed, 11 Dec 2019 22:14:55 +0000
Subject: [PATCH 046/109] Bump restapi from 1.20 to 1.21 in /e2e-test
Bumps [restapi](https://github.com/Alfresco/alfresco-tas-restapi) from 1.20 to 1.21.
- [Release notes](https://github.com/Alfresco/alfresco-tas-restapi/releases)
- [Commits](https://github.com/Alfresco/alfresco-tas-restapi/compare/v1.20...v1.21)
Signed-off-by: dependabot-preview[bot]
---
e2e-test/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml
index e14adef45..a02127e07 100644
--- a/e2e-test/pom.xml
+++ b/e2e-test/pom.xml
@@ -11,7 +11,7 @@
Search Analytics E2E Tests
Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share
- 1.20
+ 1.21
1.11
3.0.16
3.2.0
From 19fe89ce17700fb8418f38f807d8653a5679626e Mon Sep 17 00:00:00 2001
From: sridharvellingiri
Date: Thu, 12 Dec 2019 11:41:57 +0000
Subject: [PATCH 047/109] SEARCH-2011 Fix Master ReplicationHandler in script
---
search-services/packaging/src/docker/search_config_setup.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/search-services/packaging/src/docker/search_config_setup.sh b/search-services/packaging/src/docker/search_config_setup.sh
index 090a4c648..a48589f0c 100644
--- a/search-services/packaging/src/docker/search_config_setup.sh
+++ b/search-services/packaging/src/docker/search_config_setup.sh
@@ -4,7 +4,7 @@ set -e
SOLR_CONFIG_FILE=$PWD/solrhome/templates/rerank/conf/solrconfig.xml
if [[ $REPLICATION_TYPE == "master" ]]; then
- findStringMaster=''
+ findStringMaster='/'
replaceStringMaster="\n\t \n"
if [[ $REPLICATION_AFTER == "" ]]; then
REPLICATION_AFTER=commit
From 52cb47ce64141d1da3a3c5de5f1000397d1410a2 Mon Sep 17 00:00:00 2001
From: eliaporciani
Date: Thu, 12 Dec 2019 15:49:49 +0100
Subject: [PATCH 048/109] [SEARCG-1994] - solved multiple version problem on
windows. - fixed full replication not working on windows.
---
.../java/org/alfresco/solr/content/SolrContentStore.java | 4 +++-
.../java/org/alfresco/solr/handler/AlfrescoIndexFetcher.java | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
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 a11f3f4ba..bc2dc600c 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,8 @@ public final class SolrContentStore implements Closeable, AccessMode
wr.write(Long.toString(version));
wr.close();
- tmpFile.renameTo(new File(root, ".version"));
+ 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 66d676867..406736069 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
@@ -1736,7 +1736,10 @@ class AlfrescoIndexFetcher
private void cleanUpContentStore(String contentStorePath) throws Exception
{
AtomicInteger fileDeleted = new AtomicInteger();
- Set fileNames = contentStoreFilesToDownload.stream().map(e -> (String) e.get(NAME))
+ Set fileNames = contentStoreFilesToDownload.stream()
+ .map(e -> (String) e.get(NAME))
+ .map(Paths::get)
+ .map(p -> p.toString())
.collect(Collectors.toSet());
try
{
From 7567eb54c030b7f80975d0388cc6d927e976798e Mon Sep 17 00:00:00 2001
From: "dependabot-preview[bot]"
<27856297+dependabot-preview[bot]@users.noreply.github.com>
Date: Thu, 12 Dec 2019 22:13:14 +0000
Subject: [PATCH 049/109] Bump restapi from 1.21 to 1.23 in /e2e-test
Bumps [restapi](https://github.com/Alfresco/alfresco-tas-restapi) from 1.21 to 1.23.
- [Release notes](https://github.com/Alfresco/alfresco-tas-restapi/releases)
- [Commits](https://github.com/Alfresco/alfresco-tas-restapi/compare/v1.21...v1.23)
Signed-off-by: dependabot-preview[bot]
---
e2e-test/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml
index a02127e07..a0509a394 100644
--- a/e2e-test/pom.xml
+++ b/e2e-test/pom.xml
@@ -11,7 +11,7 @@
Search Analytics E2E Tests
Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share
- 1.21
+ 1.23
1.11
3.0.16
3.2.0
From c91896e9e09fc1d326d986fa55ec7485185af328 Mon Sep 17 00:00:00 2001
From: eliaporciani
Date: Fri, 13 Dec 2019 11:15:30 +0100
Subject: [PATCH 050/109] [SEARCH-1994] added comments
---
.../java/org/alfresco/solr/content/SolrContentStore.java | 1 +
.../org/alfresco/solr/handler/AlfrescoIndexFetcher.java | 7 +++++--
2 files changed, 6 insertions(+), 2 deletions(-)
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 bc2dc600c..1233ce3c1 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
@@ -258,6 +258,7 @@ public final class SolrContentStore implements Closeable, AccessMode
wr.write(Long.toString(version));
wr.close();
+ // file.renameTo(..) does not work on windows. Use Files.move instead.
Files.move(tmpFile.toPath(), new File(root, ".version").toPath(), StandardCopyOption.REPLACE_EXISTING);
}
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 406736069..c3f450755 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
@@ -1736,7 +1736,10 @@ class AlfrescoIndexFetcher
private void cleanUpContentStore(String contentStorePath) throws Exception
{
AtomicInteger fileDeleted = new AtomicInteger();
- Set fileNames = contentStoreFilesToDownload.stream()
+
+ // This is the set of the ONLY files that should be in contentStore.
+ // This set is computed from the information got from master and translated into the current OS path syntax.
+ Set contentStoreFiles = contentStoreFilesToDownload.stream()
.map(e -> (String) e.get(NAME))
.map(Paths::get)
.map(p -> p.toString())
@@ -1745,7 +1748,7 @@ class AlfrescoIndexFetcher
{
Files.walk(Paths.get(contentStorePath)).forEach(p -> {
File f = new File(p.toUri());
- if (!f.isDirectory() && !fileNames.contains(p.toString().replace(contentStorePath, "")))
+ if (!f.isDirectory() && !contentStoreFiles.contains(p.toString().replace(contentStorePath, "")))
{
try
{
From 2f918ac8cdfddeb4f90cec9d4cc7d4365310d871 Mon Sep 17 00:00:00 2001
From: eliaporciani
Date: Fri, 13 Dec 2019 11:17:10 +0100
Subject: [PATCH 051/109] [SEARCH-1994] replaced method in map
---
.../java/org/alfresco/solr/handler/AlfrescoIndexFetcher.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 c3f450755..eacc0ed07 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
@@ -1742,7 +1742,7 @@ class AlfrescoIndexFetcher
Set contentStoreFiles = contentStoreFilesToDownload.stream()
.map(e -> (String) e.get(NAME))
.map(Paths::get)
- .map(p -> p.toString())
+ .map(Path::toString)
.collect(Collectors.toSet());
try
{
From 03f58e5af9ebb7474a1096c8b795e5001de651c3 Mon Sep 17 00:00:00 2001
From: eliaporciani
Date: Fri, 13 Dec 2019 12:28:20 +0100
Subject: [PATCH 052/109] [SEARCH-1994] added comment
---
.../java/org/alfresco/solr/handler/AlfrescoIndexFetcher.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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 eacc0ed07..9b1407300 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
@@ -1738,7 +1738,9 @@ class AlfrescoIndexFetcher
AtomicInteger fileDeleted = new AtomicInteger();
// This is the set of the ONLY files that should be in contentStore.
- // This set is computed from the information got from master and translated into the current OS path syntax.
+ // This set is computed from the information got from master. After a full replication, only the files
+ // that have been downloaded from master (contentStoreFilesToDownload) should be in contentStore.
+ // The file paths are translated in the current OS path notation.
Set contentStoreFiles = contentStoreFilesToDownload.stream()
.map(e -> (String) e.get(NAME))
.map(Paths::get)
From a535688e8be512186c837cc6a2289ff332a8d074 Mon Sep 17 00:00:00 2001
From: sridharvellingiri
Date: Fri, 13 Dec 2019 11:38:28 +0000
Subject: [PATCH 053/109] SEARCH-2011 Update README about slave replica config
setup
---
README.md | 6 ++++++
search-services/packaging/src/docker/search_config_setup.sh | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 0b78fd2e7..43b13d542 100644
--- a/README.md
+++ b/README.md
@@ -41,3 +41,9 @@ 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.
+
+### 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](/insight-engine/packaging/src/docker) which will configure the slave config setup based on the value specified in the script.
diff --git a/search-services/packaging/src/docker/search_config_setup.sh b/search-services/packaging/src/docker/search_config_setup.sh
index a48589f0c..fb7636649 100644
--- a/search-services/packaging/src/docker/search_config_setup.sh
+++ b/search-services/packaging/src/docker/search_config_setup.sh
@@ -1,5 +1,7 @@
#!/bin/bash
set -e
+# By default its going to deploy "Master" setup configuration with "REPLICATION_TYPE=master".
+# Slave replica service can be enabled using "REPLICATION_TYPE=slave" environment value.
SOLR_CONFIG_FILE=$PWD/solrhome/templates/rerank/conf/solrconfig.xml
if [[ $REPLICATION_TYPE == "master" ]]; then
@@ -17,7 +19,7 @@ if [[ $REPLICATION_TYPE == "master" ]]; then
replaceStringMaster+="\t\t$REPLICATION_CONFIG_FILES<\/str> \n"
fi
replaceStringMaster+="\t<\/lst>"
- sed -i -e "s/$findStringMaster/$findStringMaster$replaceStringMaster/g" $SOLR_CONFIG_FILE
+ sed -i "s/$findStringMaster/$findStringMaster$replaceStringMaster/g" $SOLR_CONFIG_FILE
fi
if [[ $REPLICATION_TYPE == "slave" ]]; then
if [[ $REPLICATION_MASTER_PROTOCOL == "" ]]; then
From 4880c0ad278b9a4cc07f37a3aff1313bd9550856 Mon Sep 17 00:00:00 2001
From: eliaporciani
Date: Fri, 13 Dec 2019 13:45:35 +0100
Subject: [PATCH 054/109] [SEARCH-1994] use FilenameUtils.separetorToSystem to
correct path in case of master slave on different OS(e.g. windows -> linux,
linux->windows etc)
---
.../alfresco/solr/handler/AlfrescoIndexFetcher.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
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 9b1407300..1b2e4f2c5 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