@Service(value="blCatalogSolrUpdateCommandHandler") public class CatalogSolrIndexUpdateCommandHandlerImpl extends AbstractSolrIndexUpdateCommandHandlerImpl implements CatalogSolrIndexCommandHandler, org.springframework.beans.factory.DisposableBean
| Modifier and Type | Field and Description |
|---|---|
protected CatalogDocumentBuilder |
documentBuilder |
protected SolrIndexServiceExtensionManager |
extensionManager |
protected IndexFieldDao |
indexFieldDao |
protected LocaleService |
localeService |
protected int |
pageSize |
protected ProductDao |
productDao |
protected SolrIndexQueueProvider |
queueProvider |
protected long |
reindexCommitInterval |
protected SandBoxHelper |
sandBoxHelper |
protected SolrHelperService |
shs |
protected SiteService |
siteService |
protected SolrConfiguration |
solrConfiguration |
protected SolrIndexDao |
solrIndexDao |
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager |
protected int |
workerThreads |
| Constructor and Description |
|---|
CatalogSolrIndexUpdateCommandHandlerImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterBackgroundThread(ReindexStateHolder holder,
Catalog catalog,
Site site,
SandBox sandBox)
This executes after to the main execution of the background (page) thread(s).
|
protected void |
afterPage(List<Long> productIds,
List<Product> products,
List<Locale> locales,
List<IndexField> fields,
ReindexStateHolder holder)
This executes immediately after a page is processed.
|
protected void |
afterProcess(ReindexStateHolder holder)
Hook point at that is executed at the end of the reindex process.
|
protected void |
afterReadIdBatch(ReindexStateHolder holder,
Long catalogId,
int batchSize,
Long lastId)
This executes immediately after reading a batch of product IDs for processing in a background thread.
|
protected void |
afterReadProducts(ReindexStateHolder holder,
List<Long> productIds)
This executes immediately after reading a batch of products.
|
protected void |
beforeBackgroundThread(ReindexStateHolder holder,
Catalog catalog,
Site site,
SandBox sandBox)
The reindex process, specifically page processing, is executed in background threads.
|
protected void |
beforePage(List<Long> productIds,
List<Product> products,
List<Locale> locales,
List<IndexField> fields,
ReindexStateHolder holder)
This is executed immediately before a page is processed.
|
protected void |
beforeProcess(ReindexStateHolder holder)
Hook point that is executed at the beginning of the reindex process.
|
protected void |
beforeReadIdBatch(ReindexStateHolder holder,
Long catalogId,
int batchSize,
Long lastId)
This executes immediately prior to reading a batch of product IDs for processing in a background thread.
|
protected void |
beforeReadProducts(ReindexStateHolder holder,
List<Long> productIds)
This executes immediately prior to reading a batch of products.
|
org.apache.solr.common.SolrInputDocument |
buildDocument(Indexable indexable)
Provides an interface for a caller to convert an
Indexable into a SolrInputDocument. |
org.apache.solr.common.SolrInputDocument |
buildDocument(Indexable indexable,
List<IndexField> fields,
List<Locale> locales)
Provides an interface for a caller to convert an
Indexable into a SolrInputDocument. |
protected void |
buildIncrementalIndex(List<Long> productIds,
List<Product> products,
ReindexStateHolder holder,
Catalog catalog,
Site site)
Builds an incremental or batch portion of the index.
|
protected List<org.apache.solr.common.SolrInputDocument> |
buildPage(List<Long> productIds,
List<Product> products,
List<Locale> locales,
List<IndexField> fields,
ReindexStateHolder holder)
Given the arguments, this builds a list of
SolrInputDocuments. |
protected org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor |
createBackgroundOperationExecutor() |
protected EntityManagerAwareRunnable |
createBackgroundRunnable(ReindexStateHolder holder,
List<Long> ids,
Semaphore sem,
Long catalogId,
Long siteId,
SandBox sandBox)
This is where most of the heavy lifting happens.
|
protected void |
deleteAllDocuments(String collection,
boolean commit)
By default this deletes all items in the collection, since there is a good chance that the collection will be re-aliased or swapped into the foreground
after reindexing is complete.
|
void |
destroy() |
protected void |
executeCatalogReindexCommand(CatalogReindexCommand command) |
<C extends SolrUpdateCommand> |
executeCommand(C command)
Entry point from which this component can delegate action based on the type of
SolrUpdateCommand. |
protected void |
executeFullReindexCommand(FullReindexCommand command) |
protected void |
executeSiteReindexCommand(SiteReindexCommand command) |
protected void |
finalizeChanges(String collection,
boolean error,
boolean swap)
Composite method that issues a commit or rollback (if there is an error), and optionally swaps (if there is no error).
|
protected Catalog |
findCatalog(Long catalogId)
This reads a
Catalog by ID. |
protected Site |
findSite(Long siteId)
This reads a
Site by ID. |
protected List<Locale> |
getAllLocales() |
protected org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor |
getBackgroundOperationExecutor() |
protected long |
getIncrementalCommitInterval()
The amount of time between commits during a full reindex.
|
protected IdentityOperation<Void,Exception> |
getIncrementalIndexOperation(ReindexStateHolder holder,
Catalog catalog,
Site site,
List<Long> ids)
Returns an
IdentityOperation who may be executed in the context of a Catalog and/or Site to read products by IDs, and then build the index incrementally. |
protected List<IndexField> |
getIndexFields() |
protected IdentityOperation<List<Long>,Exception> |
getReadIdsOperation(ReindexStateHolder holder,
Long catalogId,
Long siteId,
Integer batchSize,
Long lastId)
Provides an
IdentityOperation (function that runs in the context of a Site and/or Catalog) to read batches of IDs. |
protected SolrConfiguration |
getSolrConfiguration() |
protected int |
getThreadsForBackgroundExecution()
Number of worker threads (page processing threads) in the thread pool.
|
protected void |
incrementalCommit(ReindexStateHolder holder)
Issues incremental commits.
|
protected boolean |
isReindexSuccessful(ReindexStateHolder holder)
Method to determine whether a full reindex was successful.
|
protected void |
performCachedOperation(SolrIndexCachedOperation.CacheOperation cacheOperation) |
protected void |
populateIndex(ReindexStateHolder holder,
Long catalogId,
Long siteId,
SandBox sandbox)
This method populates the index.
|
protected List<Long> |
readIdBatch(ReindexStateHolder holder,
Long catalogId,
int batchSize,
Long lastId)
Reads a batch of
Product IDs from the DB. |
protected List<Product> |
readProductsByIds(ReindexStateHolder holder,
List<Long> productIds)
Reads a batch of products by IDs.
|
protected void |
swapCollections() |
addDocument, addDocuments, commit, deleteByIds, deleteByQueries, deleteByQuery, executeCommandInternal, executeCommandInternal, executeCommandInternalNoDefaultCommandType, getBackgroundCollectionName, getCommandGroup, getForegroundCollectionName, rollbackclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBackgroundCollectionName, getCommandGroup, getForegroundCollectionName@Qualifier(value="blCatalogSolrConfiguration") @Autowired(required=false) protected SolrConfiguration solrConfiguration
protected LocaleService localeService
protected SolrHelperService shs
protected SiteService siteService
protected SolrIndexServiceExtensionManager extensionManager
protected org.springframework.transaction.PlatformTransactionManager transactionManager
protected SolrIndexDao solrIndexDao
protected SandBoxHelper sandBoxHelper
protected IndexFieldDao indexFieldDao
protected ProductDao productDao
protected SolrIndexQueueProvider queueProvider
protected CatalogDocumentBuilder documentBuilder
@Value(value="${solr.index.product.pageSize:100}")
protected int pageSize
@Value(value="${solr.index.product.workerThreads:10}")
protected int workerThreads
@Value(value="${solr.index.product.reindexCommitInterval:30000}")
protected long reindexCommitInterval
public CatalogSolrIndexUpdateCommandHandlerImpl()
public <C extends SolrUpdateCommand> void executeCommand(C command) throws ServiceException
SolrIndexUpdateCommandHandlerSolrUpdateCommand.
This should never be called directly. Rather it will be called from inside the AbstractSolrIndexUpdateServiceImpl.executeCommand in interface SolrIndexUpdateCommandHandlerServiceExceptionpublic org.apache.solr.common.SolrInputDocument buildDocument(Indexable indexable, List<IndexField> fields, List<Locale> locales)
SolrIndexUpdateCommandHandlerIndexable into a SolrInputDocument. This may return null if the implementor does not want
the specified Indexable indexed.buildDocument in interface SolrIndexUpdateCommandHandlerpublic org.apache.solr.common.SolrInputDocument buildDocument(Indexable indexable)
SolrIndexUpdateCommandHandlerIndexable into a SolrInputDocument. This may return null if the implementor does not want
the specified Indexable indexed.buildDocument in interface SolrIndexUpdateCommandHandlerprotected void executeFullReindexCommand(FullReindexCommand command) throws ServiceException
ServiceExceptionprotected void executeCatalogReindexCommand(CatalogReindexCommand command) throws ServiceException
ServiceExceptionprotected void executeSiteReindexCommand(SiteReindexCommand command) throws ServiceException
ServiceExceptionprotected SolrConfiguration getSolrConfiguration()
getSolrConfiguration in class AbstractSolrIndexUpdateCommandHandlerImplprotected void performCachedOperation(SolrIndexCachedOperation.CacheOperation cacheOperation) throws ServiceException
ServiceExceptionprotected void populateIndex(ReindexStateHolder holder, Long catalogId, Long siteId, SandBox sandbox) throws ServiceException
ServiceExceptionprotected IdentityOperation<List<Long>,Exception> getReadIdsOperation(ReindexStateHolder holder, Long catalogId, Long siteId, Integer batchSize, Long lastId)
IdentityOperation (function that runs in the context of a Site and/or Catalog) to read batches of IDs.holder - catalogId - siteId - batchSize - lastId - protected void deleteAllDocuments(String collection, boolean commit) throws ServiceException
collection - commit - ServiceExceptionprotected void finalizeChanges(String collection, boolean error, boolean swap) throws ServiceException
collection - error - swap - ServiceExceptionprotected void swapCollections()
throws ServiceException
ServiceExceptionpublic void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionprotected org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor getBackgroundOperationExecutor()
protected int getThreadsForBackgroundExecution()
protected org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor createBackgroundOperationExecutor()
protected EntityManagerAwareRunnable createBackgroundRunnable(ReindexStateHolder holder, List<Long> ids, Semaphore sem, Long catalogId, Long siteId, SandBox sandBox)
collectionName - holder - sem - incrementalCommits - protected IdentityOperation<Void,Exception> getIncrementalIndexOperation(ReindexStateHolder holder, Catalog catalog, Site site, List<Long> ids)
IdentityOperation who may be executed in the context of a Catalog and/or Site to read products by IDs, and then build the index incrementally.holder - catalog - site - ids - protected List<org.apache.solr.common.SolrInputDocument> buildPage(List<Long> productIds, List<Product> products, List<Locale> locales, List<IndexField> fields, ReindexStateHolder holder) throws Exception
SolrInputDocuments. This does not write them to Solr.productIds - products - locales - fields - holder - Exceptionprotected List<Product> readProductsByIds(ReindexStateHolder holder, List<Long> productIds) throws Exception
holder - productIds - Exceptionprotected List<IndexField> getIndexFields()
protected void buildIncrementalIndex(List<Long> productIds, List<Product> products, ReindexStateHolder holder, Catalog catalog, Site site) throws Exception
Locales and IndexFields, building a page,
adding the documents to the index, and incrementally committing. It is not recommended that you override this method. Rather, consider overriding
one of the other methods as this is largely responsible for orchestrating and delegating.productIds - products - holder - catalog - site - Exceptionprotected List<Long> readIdBatch(ReindexStateHolder holder, Long catalogId, int batchSize, Long lastId) throws Exception
Product IDs from the DB.holder - catalogId - batchSize - lastId - Exceptionprotected void beforeProcess(ReindexStateHolder holder) throws ServiceException
holder - ServiceExceptionprotected void afterProcess(ReindexStateHolder holder) throws ServiceException
ReindexStateHolder to determine if an error has occured during the process.holder - ServiceExceptionprotected void beforeBackgroundThread(ReindexStateHolder holder, Catalog catalog, Site site, SandBox sandBox) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.holder - catalog - site - sandBox - ServiceExceptionprotected void afterBackgroundThread(ReindexStateHolder holder, Catalog catalog, Site site, SandBox sandBox) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.holder - catalog - site - sandBox - ServiceExceptionprotected void beforePage(List<Long> productIds, List<Product> products, List<Locale> locales, List<IndexField> fields, ReindexStateHolder holder) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.productIds - products - locales - fields - holder - ServiceExceptionprotected void afterPage(List<Long> productIds, List<Product> products, List<Locale> locales, List<IndexField> fields, ReindexStateHolder holder) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.productIds - products - locales - fields - holder - ServiceExceptionprotected void beforeReadProducts(ReindexStateHolder holder, List<Long> productIds) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.holder - productIds - ServiceExceptionprotected void afterReadProducts(ReindexStateHolder holder, List<Long> productIds) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.holder - productIds - ServiceExceptionprotected void beforeReadIdBatch(ReindexStateHolder holder, Long catalogId, int batchSize, Long lastId) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.holder - catalogId - batchSize - lastId - ServiceExceptionprotected void afterReadIdBatch(ReindexStateHolder holder, Long catalogId, int batchSize, Long lastId) throws ServiceException
ReindexStateHolder to determine if an error has occurred during the process.holder - catalogId - batchSize - lastId - ServiceExceptionprotected Catalog findCatalog(Long catalogId)
Catalog by ID. If the ID is null (default, unless in Multi-Tenant mode), this returns null.catalogId - protected Site findSite(Long siteId)
Site by ID. If the ID is null (default, unless in Multi-Tenant mode), this returns null.siteId - protected long getIncrementalCommitInterval()
protected void incrementalCommit(ReindexStateHolder holder) throws Exception
holder - Exceptionprotected boolean isReindexSuccessful(ReindexStateHolder holder)
ReindexStateHolder.isFailed() returns false
and that at least 1 document was indexed. Implementors may wish to
override this to determine whether the ReindexStateHolder.getIndexableCount() is a certain number,
or if ReindexStateHolder.getUnindexedItemCount() is at least a percentage of total items or of the items that were indexed, given
that the failure to build a single document / product does not stop the reindex process.holder - Copyright © 2026. All rights reserved.