Class AbstractSolrIndexUpdateServiceImpl
- All Implemented Interfaces:
SolrIndexUpdateService,org.springframework.beans.factory.DisposableBean
- Direct Known Subclasses:
CatalogSolrIndexUpdateServiceImpl
This component makes use of a Lock and a BlockingQueue. The providers for these components, SolrIndexQueueProvider and
SolrIndexLockProvider provide an isDistributed() method. They must both return the same value. Note that if
isDistributed() returns false, then care must be taken to ensure that 2 or more nodes (i.e. JVMs) cannot execute at the same time.
This is typically done by ensuring that only a single node will receive calls/events to update a Solr index.
- Author:
- Kelly Tisdell
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractSolrIndexUpdateServiceImpl(String commandGroup, SolrIndexQueueProvider queueProvider, SolrIndexUpdateCommandHandler commandHandler) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.solr.common.SolrInputDocumentbuildDocument(Indexable indexable) Provides an interface for a caller to convert anIndexableinto aSolrInputDocument.org.apache.solr.common.SolrInputDocumentbuildDocument(Indexable indexable, List<IndexField> fields, List<Locale> locales) Provides an interface for a caller to convert anIndexableinto aSolrInputDocument.voiddestroy()final StringThis is any arbitrary name to identify or group commands, typically based on the Solr index (or indexes) being updated.protected longAmount of time that will be waited, assuming the queue is full, for space to become available in the queue.protected longAmount of time in millis that the queue will be polled before returning an item or null.static booleanvoidDefault behavior is to truncate the background collection (offline index), populate it with documents, commit, and then swap (re-alias) so that it becomes the foreground collection and the foreground collection becomes the background.protected final <C extends SolrUpdateCommand>
voidscheduleCommand(C command) static voidStops all threads that are listening to various command queues.voidupdateIndex(List<org.apache.solr.common.SolrInputDocument> documents) This is for relatively small, autonomous, incremental updates to the main (customer-facing) foreground Solr collection / index.voidupdateIndex(List<org.apache.solr.common.SolrInputDocument> documents, List<String> deleteQueries) This is for relatively small, autonomous, incremental updates to the main (customer-facing) foreground Solr collection / index.
-
Constructor Details
-
AbstractSolrIndexUpdateServiceImpl
public AbstractSolrIndexUpdateServiceImpl(String commandGroup, SolrIndexQueueProvider queueProvider, SolrIndexUpdateCommandHandler commandHandler)
-
-
Method Details
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-
shutdownAll
public static void shutdownAll()Stops all threads that are listening to various command queues. -
getCommandGroup
This is any arbitrary name to identify or group commands, typically based on the Solr index (or indexes) being updated. For example, "catalog" will likely be a command identifier. It could also be "product", but in less common cases where you want to index categories or other things with products and you want to serialize those commands, then this can assist.- Returns:
-
scheduleCommand
-
isRunning
-
rebuildIndex
Description copied from interface:SolrIndexUpdateServiceDefault behavior is to truncate the background collection (offline index), populate it with documents, commit, and then swap (re-alias) so that it becomes the foreground collection and the foreground collection becomes the background.- Specified by:
rebuildIndexin interfaceSolrIndexUpdateService- Throws:
ServiceException
-
updateIndex
Description copied from interface:SolrIndexUpdateServiceThis is for relatively small, autonomous, incremental updates to the main (customer-facing) foreground Solr collection / index.Writes the documents to the foreground collection / index. Then issues a commit.
This should not be used for incremental indexing in the context of a larger indexing scope or operation.
- Specified by:
updateIndexin interfaceSolrIndexUpdateService
-
updateIndex
public void updateIndex(List<org.apache.solr.common.SolrInputDocument> documents, List<String> deleteQueries) Description copied from interface:SolrIndexUpdateServiceThis is for relatively small, autonomous, incremental updates to the main (customer-facing) foreground Solr collection / index.Executes the delete queries, if any, in the foreground index. Then writes the documents, if any, to the foreground index. Then commits if no errors occur.
This should not be used for incremental indexing in the context of a larger indexing scope or operation.
- Specified by:
updateIndexin interfaceSolrIndexUpdateService
-
buildDocument
Description copied from interface:SolrIndexUpdateServiceProvides an interface for a caller to convert anIndexableinto aSolrInputDocument. This may return null if the implementor does not want the specifiedIndexableindexed.- Specified by:
buildDocumentin interfaceSolrIndexUpdateService- Returns:
-
buildDocument
public org.apache.solr.common.SolrInputDocument buildDocument(Indexable indexable, List<IndexField> fields, List<Locale> locales) Description copied from interface:SolrIndexUpdateServiceProvides an interface for a caller to convert anIndexableinto aSolrInputDocument. This may return null if the implementor does not want the specifiedIndexableindexed.- Specified by:
buildDocumentin interfaceSolrIndexUpdateService- Returns:
-
getQueuePollTime
protected long getQueuePollTime()Amount of time in millis that the queue will be polled before returning an item or null. Default is 1 minute (60000 ms). If you override this method, it must return a positive long value, preferrably greater than 60000 to reduce the polling cycles.- Returns:
-
getQueueOfferTime
protected long getQueueOfferTime()Amount of time that will be waited, assuming the queue is full, for space to become available in the queue. Default is 1 second (1000 ms).- Returns:
-