Class MetadataTracker

All Implemented Interfaces:
Tracker

public class MetadataTracker extends ActivatableTracker
  • Field Details

    • LOGGER

      protected static final org.slf4j.Logger LOGGER
  • Constructor Details

    • MetadataTracker

      public MetadataTracker(Properties p, org.alfresco.solr.client.SOLRAPIClient client, String coreName, InformationServer informationServer)
    • MetadataTracker

      public MetadataTracker(Properties p, org.alfresco.solr.client.SOLRAPIClient client, String coreName, InformationServer informationServer, boolean checkRepoServicesAvailability)
      MetadataTracker constructor
      Parameters:
      p - includes SOLR core properties (from environment variables and properties file)
      client - Alfresco Repository http client
      coreName - Name of the SOLR Core (alfresco, archive)
      informationServer - SOLR Information Server
      checkRepoServicesAvailability - is true if Repo Services availability needs to be checked
  • Method Details

    • getWriteLock

      public Semaphore getWriteLock()
      Description copied from class: AbstractTracker
      Trackers implementing this method should decide if the Write Lock is applied globally for every Tracker Thread (static) or locally for each running Thread
      Specified by:
      getWriteLock in interface Tracker
      Specified by:
      getWriteLock in class AbstractTracker
    • getRunLock

      public Semaphore getRunLock()
      Description copied from class: AbstractTracker
      Trackers implementing this method should decide if the Run Lock is applied globally for every Tracker Thread (static) or locally for each running Thread
      Specified by:
      getRunLock in class AbstractTracker
    • doTrack

      protected void doTrack(String iterationId) throws org.alfresco.httpclient.AuthenticationException, IOException, org.json.JSONException
      Description copied from class: AbstractTracker
      Subclasses must implement behaviour that completes the following steps, in order:
      1. Purge
      2. Reindex
      3. Index
      4. Track repository
      Specified by:
      doTrack in class AbstractTracker
      Parameters:
      iterationId - an identifier which is uniquely associated with a given iteration.
      Throws:
      org.alfresco.httpclient.AuthenticationException
      IOException
      org.json.JSONException
    • maintenance

      public void maintenance() throws Exception
      Throws:
      Exception
    • hasMaintenance

      public boolean hasMaintenance()
    • getTxFromCommitTime

      protected Long getTxFromCommitTime(org.alfresco.solr.BoundedDeque<org.alfresco.solr.client.Transaction> txnsFound, long lastGoodTxCommitTimeInIndex)
      The fromCommitTime tells getSomeTransactions() where to start, this actually fairly straight forward. What makes this code so tricky to understand is the state.getTimeToStopIndexing(). There are two scenarios to keep in mind: 1) Full re-index: In this scenario the state.getTimeToStopIndexing() will never stop the indexing. 2) Up-to-date indexing: This is where state.getTimeToStopIndexing() gets interesting. In this scenario the Solr index is already up to date with the repo and it is tracking new transactions. The state.getTimeToStopIndexing() in this scenario causes the getSomeTransactions() call to stop returning results if it finds a transaction beyond a specific point in time. This will break out of this loop and end the tracker run. The next time the metadata tracker runs the "continueState()" method applies the "hole retention" to state.getLastGoodTxCommitTimeInIndex(). This causes the state.getLastGoodTxCommitTimeInIndex() to scan for prior transactions that might have been missed.
    • getSomeTransactions

      protected org.alfresco.solr.client.Transactions getSomeTransactions(org.alfresco.solr.BoundedDeque<org.alfresco.solr.client.Transaction> txnsFound, Long fromCommitTime, long timeStep, int maxResults, long endTime) throws org.alfresco.httpclient.AuthenticationException, IOException, org.json.JSONException, org.apache.commons.codec.EncoderException, NoSuchMethodException
      Throws:
      org.alfresco.httpclient.AuthenticationException
      IOException
      org.json.JSONException
      org.apache.commons.codec.EncoderException
      NoSuchMethodException
    • trackTransactions

      protected void trackTransactions() throws IOException, org.json.JSONException
      Indexing new transactions from repository in batches of "transactionDocsBatchSize" size. Additionally, the nodes inside a transaction batch are indexed in batches of "nodeBatchSize" size.
      Throws:
      IOException
      org.json.JSONException
    • checkNode

      public org.alfresco.solr.NodeReport checkNode(Long dbid)
      Description copied from class: AbstractTracker
      Returns information about the Node associated with the given dbid.
      Overrides:
      checkNode in class AbstractTracker
      Parameters:
      dbid - the node identifier.
      Returns:
      the Node associated with the given dbid.
    • checkNode

      public org.alfresco.solr.NodeReport checkNode(org.alfresco.solr.client.Node node)
    • getFullNodesForDbTransaction

      public List<org.alfresco.solr.client.Node> getFullNodesForDbTransaction(Long txid)
    • checkIndex

      public org.alfresco.solr.tracker.IndexHealthReport checkIndex(Long toTx, Long fromTime, Long toTime) throws IOException, org.alfresco.httpclient.AuthenticationException, org.json.JSONException, org.apache.commons.codec.EncoderException, NoSuchMethodException
      Throws:
      IOException
      org.alfresco.httpclient.AuthenticationException
      org.json.JSONException
      org.apache.commons.codec.EncoderException
      NoSuchMethodException
    • addTransactionToPurge

      public void addTransactionToPurge(Long txId)
    • addNodeToPurge

      public void addNodeToPurge(Long nodeId)
    • addTransactionToReindex

      public void addTransactionToReindex(Long txId)
    • addNodeToReindex

      public void addNodeToReindex(Long nodeId)
    • addTransactionToIndex

      public void addTransactionToIndex(Long txId)
    • clearScheduledMaintenanceWork

      protected void clearScheduledMaintenanceWork()
      Description copied from class: ActivatableTracker
      Cleans up the scheduled maintenance work collected by this tracker.
      Overrides:
      clearScheduledMaintenanceWork in class ActivatableTracker
    • addNodeToIndex

      public void addNodeToIndex(Long nodeId)
    • invalidateState

      public void invalidateState()
      Specified by:
      invalidateState in interface Tracker
      Overrides:
      invalidateState in class AbstractTracker
    • addQueryToReindex

      public void addQueryToReindex(String query)