[MNT-23250] Added minTxnIdRange (#2020)

This commit is contained in:
purusothaman-mm
2024-05-03 11:02:51 +05:30
committed by GitHub
parent 83e3f27f77
commit 01f00f8ff5
2 changed files with 39 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Search Services
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -79,7 +79,6 @@ public class MetadataTracker extends ActivatableTracker
private static final int DEFAULT_NODE_BATCH_SIZE = 50;
private static final String DEFAULT_INITIAL_TRANSACTION_RANGE = "0-2000";
private static final long DEFAULT_METADATA_TRACKER_TIMESTEP = TIME_STEP_1_HR_IN_MS;
private static final long INITIAL_MAX_TXN_ID = 2000L;
private int matadataTrackerParallelism;
private int transactionDocsBatchSize;
@@ -355,8 +354,8 @@ public class MetadataTracker extends ActivatableTracker
// No firstTransaction checking is required for this case.
if (minCommitTime != -1L) {
firstTransactions = client.getTransactions(minCommitTime, 0L,
null, INITIAL_MAX_TXN_ID, 1);
firstTransactions = client.getTransactions(minCommitTime, minTxnIdRange.getFirst(),
null, minTxnIdRange.getSecond(), 1);
if (!firstTransactions.getTransactions().isEmpty())
{
Transaction firstTransaction = firstTransactions.getTransactions().get(0);
@@ -1262,8 +1261,8 @@ public class MetadataTracker extends ActivatableTracker
{
// DB TX Count
long firstTransactionCommitTime = 0;
Transactions firstTransactions = client.getTransactions(null, 0L,
null, INITIAL_MAX_TXN_ID, 1);
Transactions firstTransactions = client.getTransactions(null, minTxnIdRange.getFirst(),
null, minTxnIdRange.getSecond(), 1);
if(firstTransactions.getTransactions().size() > 0)
{
Transaction firstTransaction = firstTransactions.getTransactions().get(0);

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Search Services
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2024 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -33,6 +33,7 @@ import java.util.Properties;
import org.alfresco.httpclient.AuthenticationException;
import org.alfresco.repo.index.shard.ShardState;
import org.alfresco.solr.AlfrescoCoreAdminHandler;
import org.alfresco.solr.InformationServer;
import org.alfresco.solr.NodeReport;
import org.alfresco.solr.TrackerState;
@@ -66,6 +67,7 @@ import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -94,6 +96,7 @@ public class MetadataTrackerTest
@Before
public void setUp()
{
doReturn("0-2000").when(props).getProperty("solr.initial.transaction.range");
doReturn("workspace://SpacesStore").when(props).getProperty("alfresco.stores");
when(srv.getTrackerStats()).thenReturn(trackerStats);
String coreName = "theCoreName";
@@ -281,4 +284,34 @@ public class MetadataTrackerTest
node.setTxnId(TX_ID);
return node;
}
@Test
public void testCheckRepoAndIndexConsistency() throws AuthenticationException, IOException, JSONException
{
TrackerState state = new TrackerState();
ModelTracker modelTracker = mock(ModelTracker.class);
when(modelTracker.hasModels()).thenReturn(true);
when(this.metadataTracker.getTrackerState()).thenReturn(state);
TrackerRegistry registry = new TrackerRegistry();
registry.setModelTracker(modelTracker);
AlfrescoCoreAdminHandler alfrescoCoreAdminHandler = mock(AlfrescoCoreAdminHandler.class);
when(this.srv.getAdminHandler()).thenReturn(alfrescoCoreAdminHandler);
when(alfrescoCoreAdminHandler.getTrackerRegistry()).thenReturn(registry);
List<Transaction> txsList = new ArrayList<>();
Transaction tx1 = new Transaction();
tx1.setCommitTimeMs(1L);
tx1.setDeletes(1);
tx1.setUpdates(1);
txsList.add(tx1);
Transactions txs = new Transactions(txsList, 0L, 2000L);
when(repositoryClient.getTransactions(null, 0L, null, 2000L, 1)).thenReturn(txs);
when(repositoryClient.getTransactions(1L, null, 3600001L, null, 2000)).thenReturn(txs);
this.metadataTracker.doTrack("AnIterationId");
verify(this.metadataTracker, times(1)).doTrack("AnIterationId");
}
}