Package org.alfresco.solr.tracker
Class MetadataTracker
java.lang.Object
org.alfresco.solr.tracker.AbstractTracker
org.alfresco.solr.tracker.ActivatableTracker
org.alfresco.solr.tracker.MetadataTracker
- All Implemented Interfaces:
Tracker
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.alfresco.solr.tracker.Tracker
Tracker.Type -
Field Summary
FieldsFields inherited from class org.alfresco.solr.tracker.ActivatableTracker
isEnabledFields inherited from class org.alfresco.solr.tracker.AbstractTracker
client, coreName, props, rollback, rollbackCausedBy, shardCount, shardInstance, shardKey, shardProperty, state, trackerId, transformContent, type -
Constructor Summary
ConstructorsConstructorDescriptionMetadataTracker(Properties p, org.alfresco.solr.client.SOLRAPIClient client, String coreName, InformationServer informationServer) MetadataTracker(Properties p, org.alfresco.solr.client.SOLRAPIClient client, String coreName, InformationServer informationServer, boolean checkRepoServicesAvailability) MetadataTracker constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNodeToIndex(Long nodeId) voidaddNodeToPurge(Long nodeId) voidaddNodeToReindex(Long nodeId) voidaddQueryToReindex(String query) voidaddTransactionToIndex(Long txId) voidaddTransactionToPurge(Long txId) voidaddTransactionToReindex(Long txId) org.alfresco.solr.tracker.IndexHealthReportcheckIndex(Long toTx, Long fromTime, Long toTime) org.alfresco.solr.NodeReportReturns information about theNodeassociated with the given dbid.org.alfresco.solr.NodeReportcheckNode(org.alfresco.solr.client.Node node) protected voidCleans up the scheduled maintenance work collected by this tracker.protected voidSubclasses must implement behaviour that completes the following steps, in order: Purge Reindex Index Track repositoryList<org.alfresco.solr.client.Node>Trackers implementing this method should decide if the Run Lock is applied globally for every Tracker Thread (static) or locally for each running Threadprotected org.alfresco.solr.client.TransactionsgetSomeTransactions(org.alfresco.solr.BoundedDeque<org.alfresco.solr.client.Transaction> txnsFound, Long fromCommitTime, long timeStep, int maxResults, long endTime) protected LonggetTxFromCommitTime(org.alfresco.solr.BoundedDeque<org.alfresco.solr.client.Transaction> txnsFound, long lastGoodTxCommitTimeInIndex) The fromCommitTime tells getSomeTransactions() where to start, this actually fairly straight forward.Trackers implementing this method should decide if the Write Lock is applied globally for every Tracker Thread (static) or locally for each running Threadbooleanvoidvoidprotected voidIndexing new transactions from repository in batches of "transactionDocsBatchSize" size.Methods inherited from class org.alfresco.solr.tracker.ActivatableTracker
disable, enable, isDisabled, isEnabled, logAndClear, trackMethods inherited from class org.alfresco.solr.tracker.AbstractTracker
getDocRouter, getProps, getRollback, getRollbackCausedBy, getTrackerState, getType, isAlreadyInShutDownMode, setRollback, setShutdown, shutdown
-
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 clientcoreName- Name of the SOLR Core (alfresco, archive)informationServer- SOLR Information ServercheckRepoServicesAvailability- is true if Repo Services availability needs to be checked
-
-
Method Details
-
getWriteLock
Description copied from class:AbstractTrackerTrackers 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:
getWriteLockin interfaceTracker- Specified by:
getWriteLockin classAbstractTracker
-
getRunLock
Description copied from class:AbstractTrackerTrackers 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:
getRunLockin classAbstractTracker
-
doTrack
protected void doTrack(String iterationId) throws org.alfresco.httpclient.AuthenticationException, IOException, org.json.JSONException Description copied from class:AbstractTrackerSubclasses must implement behaviour that completes the following steps, in order:- Purge
- Reindex
- Index
- Track repository
- Specified by:
doTrackin classAbstractTracker- Parameters:
iterationId- an identifier which is uniquely associated with a given iteration.- Throws:
org.alfresco.httpclient.AuthenticationExceptionIOExceptionorg.json.JSONException
-
maintenance
- 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.AuthenticationExceptionIOExceptionorg.json.JSONExceptionorg.apache.commons.codec.EncoderExceptionNoSuchMethodException
-
trackTransactions
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:
IOExceptionorg.json.JSONException
-
checkNode
Description copied from class:AbstractTrackerReturns information about theNodeassociated with the given dbid.- Overrides:
checkNodein classAbstractTracker- Parameters:
dbid- the node identifier.- Returns:
- the
Nodeassociated with the given dbid.
-
checkNode
public org.alfresco.solr.NodeReport checkNode(org.alfresco.solr.client.Node node) -
getFullNodesForDbTransaction
-
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:
IOExceptionorg.alfresco.httpclient.AuthenticationExceptionorg.json.JSONExceptionorg.apache.commons.codec.EncoderExceptionNoSuchMethodException
-
addTransactionToPurge
-
addNodeToPurge
-
addTransactionToReindex
-
addNodeToReindex
-
addTransactionToIndex
-
clearScheduledMaintenanceWork
protected void clearScheduledMaintenanceWork()Description copied from class:ActivatableTrackerCleans up the scheduled maintenance work collected by this tracker.- Overrides:
clearScheduledMaintenanceWorkin classActivatableTracker
-
addNodeToIndex
-
invalidateState
public void invalidateState()- Specified by:
invalidateStatein interfaceTracker- Overrides:
invalidateStatein classAbstractTracker
-
addQueryToReindex
-