Search in sources :

Example 6 with TrackerState

use of org.alfresco.solr.TrackerState in project SearchServices by Alfresco.

the class MetadataTrackerTest method doTrackWithOneTransactionUpdatesOnce.

@Test
@Ignore("Superseded by AlfrescoSolrTrackerTest")
public void doTrackWithOneTransactionUpdatesOnce() throws AuthenticationException, IOException, JSONException, EncoderException {
    TrackerState state = new TrackerState();
    state.setTimeToStopIndexing(2L);
    when(srv.getTrackerInitialState()).thenReturn(state);
    // TrackerState is persisted per tracker
    when(this.metadataTracker.getTrackerState()).thenReturn(state);
    List<Transaction> txsList = new ArrayList<>();
    Transaction tx = new Transaction();
    tx.setCommitTimeMs(1L);
    tx.setDeletes(1);
    tx.setUpdates(1);
    txsList.add(tx);
    Transactions txs = mock(Transactions.class);
    when(txs.getTransactions()).thenReturn(txsList);
    // Subsequent calls to getTransactions must return a different set of transactions to avoid an infinite loop
    when(repositoryClient.getTransactions(anyLong(), anyLong(), anyLong(), anyLong(), anyInt())).thenReturn(txs).thenReturn(txs).thenReturn(mock(Transactions.class));
    when(repositoryClient.getTransactions(anyLong(), anyLong(), anyLong(), anyLong(), anyInt(), isNull(ShardState.class))).thenReturn(txs).thenReturn(txs).thenReturn(mock(Transactions.class));
    when(repositoryClient.getTransactions(anyLong(), anyLong(), anyLong(), anyLong(), anyInt(), any(ShardState.class))).thenReturn(txs).thenReturn(txs).thenReturn(mock(Transactions.class));
    List<Node> nodes = new ArrayList<>();
    Node node = new Node();
    nodes.add(node);
    when(repositoryClient.getNodes(any(GetNodesParameters.class), anyInt())).thenReturn(nodes);
    this.metadataTracker.doTrack();
    InOrder inOrder = inOrder(srv);
    inOrder.verify(srv).indexNodes(nodes, true, false);
    inOrder.verify(srv).indexTransaction(tx, true);
    inOrder.verify(srv).commit();
}
Also used : Transactions(org.alfresco.solr.client.Transactions) ShardState(org.alfresco.repo.index.shard.ShardState) InOrder(org.mockito.InOrder) Transaction(org.alfresco.solr.client.Transaction) Node(org.alfresco.solr.client.Node) GetNodesParameters(org.alfresco.solr.client.GetNodesParameters) ArrayList(java.util.ArrayList) TrackerState(org.alfresco.solr.TrackerState) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with TrackerState

use of org.alfresco.solr.TrackerState in project SearchServices by Alfresco.

the class AclTracker method trackRepository.

protected void trackRepository() throws IOException, AuthenticationException, JSONException {
    checkShutdown();
    if (!isMaster && isSlave) {
        return;
    }
    TrackerState state = super.getTrackerState();
    // Check we are tracking the correct repository
    if (state.getTrackerCycles() == 0) {
        // We have a new tracker state so do the checks.
        checkRepoAndIndexConsistency(state);
    }
    checkShutdown();
    trackAclChangeSets();
}
Also used : TrackerState(org.alfresco.solr.TrackerState)

Aggregations

TrackerState (org.alfresco.solr.TrackerState)7 ShardState (org.alfresco.repo.index.shard.ShardState)4 ArrayList (java.util.ArrayList)2 Transaction (org.alfresco.solr.client.Transaction)2 Transactions (org.alfresco.solr.client.Transactions)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Properties (java.util.Properties)1 AlfrescoCoreAdminHandler (org.alfresco.solr.AlfrescoCoreAdminHandler)1 GetNodesParameters (org.alfresco.solr.client.GetNodesParameters)1 Node (org.alfresco.solr.client.Node)1 MetadataTracker (org.alfresco.solr.tracker.MetadataTracker)1 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)1 Before (org.junit.Before)1 InOrder (org.mockito.InOrder)1