Package io.jmix.search.index.queue.impl
Class JpaIndexingQueueManager
java.lang.Object
io.jmix.search.index.queue.impl.JpaIndexingQueueManager
- All Implemented Interfaces:
IndexingQueueManager
@Component("search_JpaIndexingQueueManager")
public class JpaIndexingQueueManager
extends Object
implements IndexingQueueManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classAnalyzes collection ofIndexingQueueItem, determines unique entity ids and splits them among two disjoint groups: for index and for delete. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SystemAuthenticatorprotected UnconstrainedDataManagerprotected EnqueueingSessionManagerprotected EntityIdsLoaderProviderprotected EntityIndexerprotected IdSerializationprotected IndexConfigurationManagerprotected IndexStateRegistryprotected IndexingLockerprotected Metadataprotected MetadataToolsprotected SearchPropertiesprotected StoreAwareLocator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected LoadContext<IndexingQueueItem>createDequeueLoadContext(List<String> unavailableEntities, int batchSize) protected IndexingQueueItemcreateQueueItem(MetaClass metaClass, String entityId, IndexingOperation operation) protected IndexingQueueItemcreateQueueItem(String entityName, String entityId, IndexingOperation operation) intRemoves all queue items.intemptyQueue(String entityName) Removes all queue items related to provided entity.protected intenqueue(Collection<IndexingQueueItem> queueItems) protected intenqueue(Collection<Object> entityInstances, IndexingOperation operation) protected intenqueueByIds(Collection<Id<?>> entityIds, IndexingOperation operation) intenqueueDelete(Object entityInstance) Sends provided entity instance to indexing queue in order to delete it from index.intenqueueDeleteByEntityId(Id<?> entityId) Sends entity instance to indexing queue by provided ID in order to delete it from index.intenqueueDeleteCollection(Collection<Object> entityInstances) Sends provided entity instances to indexing queue in order to delete them from index.intenqueueDeleteCollectionByEntityIds(Collection<Id<?>> entityIds) Sends entity instances to indexing queue by provided IDs in order to delete them from index.intenqueueIndex(Object entityInstance) Sends provided entity instance to indexing queue in order to store it to index.intSynchronously sends all instances of all index-configured entities to indexing queue.intenqueueIndexAll(String entityName) Synchronously sends all instances of provided entity to indexing queue.protected intenqueueIndexAll(String entityName, int batchSize) intenqueueIndexByEntityId(Id<?> entityId) Sends entity instance to indexing queue by provided ID in order to store it to index.intenqueueIndexCollection(Collection<Object> entityInstances) Sends provided entity instances to indexing queue in order to store them to index.intenqueueIndexCollectionByEntityIds(Collection<Id<?>> entityIds) Sends entity instances to indexing queue by provided IDs in order to store them to index.protected intenqueueNextBatchInternal(EnqueueingSession session, int batchSize) Gets entity names of all existing enqueueing sessions.protected Map<IndexingOperation,Map<Id<?>, List<IndexingQueueItem>>> groupQueueItems(Collection<IndexingQueueItem> queueItems) protected List<IndexingQueueItem>handleIndexResult(IndexResult indexResult, Map<Id<?>, List<IndexingQueueItem>> itemsGroup) voidInitializes async enqueueing session for all indexed entities.booleaninitAsyncEnqueueIndexAll(String entityName) Initializes async enqueueing session for provided entity.protected List<?>loadRawIds(MetaClass metaClass) protected intprocessEnqueueingSession(EnqueueingSession session, int batchSize) intprocessEnqueueingSession(String entityName) Processes enqueueing session for provided entity - one batch (with default size) of entity instances will be enqueued.intprocessEnqueueingSession(String entityName, int batchSize) Processes enqueueing session for provided entity - one batch (with provided size) of entity instances will be enqueued.intRetrieves items from indexing queue and processes them - store/remove related documents in index.intprocessEntireQueue(int batchSize) Retrieves items from indexing queue and processes them - store/remove related documents in index.intRetrieves next batch of items from indexing queue and processes them - store/remove related documents in index.intprocessNextBatch(int batchSize) Retrieves next batch of items from indexing queue and processes them - store/remove related documents in index.intProcesses next available enqueueing session - one batch (with default size) of entity instances will be enqueued.intprocessNextEnqueueingSession(int batchSize) Processes next available enqueueing session - one batch (with provided size) of entity instances will be enqueued.protected intprocessQueue(int batchSize, boolean processEntireQueue) protected List<IndexingQueueItem>processQueueItems(List<IndexingQueueItem> queueItems) protected List<IndexingQueueItem>processQueueItemsGroup(Map<Id<?>, List<IndexingQueueItem>> itemsGroup, Function<Collection<Id<?>>, IndexResult> processingFunction) protected intprocessRawIds(List<?> rawIds, MetaClass metaClass, int batchSize) voidResumes all previously suspended enqueueing sessions.booleanresumeAsyncEnqueueIndexAll(String entityName) Resumes previously suspended enqueueing session for provided entity.voidSuspends all enqueueing sessions.booleansuspendAsyncEnqueueIndexAll(String entityName) Suspends enqueueing session for provided entity.voidTerminates all enqueueing sessions.booleanterminateAsyncEnqueueIndexAll(String entityName) Terminates enqueueing session for provided entity.
-
Field Details
-
dataManager
-
metadata
-
metadataTools
-
entityIndexer
-
storeAwareLocator
-
indexConfigurationManager
-
idSerialization
-
authenticator
-
locker
-
searchProperties
-
indexStateRegistry
-
enqueueingSessionManager
-
entityIdsLoaderProvider
-
-
Constructor Details
-
JpaIndexingQueueManager
public JpaIndexingQueueManager()
-
-
Method Details
-
emptyQueue
public int emptyQueue()Description copied from interface:IndexingQueueManagerRemoves all queue items.- Specified by:
emptyQueuein interfaceIndexingQueueManager- Returns:
- amount of deleted items
-
emptyQueue
Description copied from interface:IndexingQueueManagerRemoves all queue items related to provided entity.- Specified by:
emptyQueuein interfaceIndexingQueueManager- Parameters:
entityName- entity- Returns:
- amount of deleted items
-
enqueueIndex
Description copied from interface:IndexingQueueManagerSends provided entity instance to indexing queue in order to store it to index.- Specified by:
enqueueIndexin interfaceIndexingQueueManager- Parameters:
entityInstance- instance- Returns:
- amount of enqueued instances
-
enqueueIndexCollection
Description copied from interface:IndexingQueueManagerSends provided entity instances to indexing queue in order to store them to index.- Specified by:
enqueueIndexCollectionin interfaceIndexingQueueManager- Parameters:
entityInstances- instances- Returns:
- amount of enqueued instances
-
enqueueIndexByEntityId
Description copied from interface:IndexingQueueManagerSends entity instance to indexing queue by provided ID in order to store it to index.- Specified by:
enqueueIndexByEntityIdin interfaceIndexingQueueManager- Parameters:
entityId- ID of entity instance- Returns:
- amount of enqueued instances
-
enqueueIndexCollectionByEntityIds
Description copied from interface:IndexingQueueManagerSends entity instances to indexing queue by provided IDs in order to store them to index.- Specified by:
enqueueIndexCollectionByEntityIdsin interfaceIndexingQueueManager- Parameters:
entityIds- IDs of entity instances- Returns:
- amount of enqueued instances
-
enqueueIndexAll
public int enqueueIndexAll()Description copied from interface:IndexingQueueManagerSynchronously sends all instances of all index-configured entities to indexing queue.Don't use it on a huge amount of data - all ids (per entity) will be kept in memory during this process. Use
IndexingQueueManager.initAsyncEnqueueIndexAll()methods instead.- Specified by:
enqueueIndexAllin interfaceIndexingQueueManager- Returns:
- amount of enqueued instances
-
enqueueIndexAll
Description copied from interface:IndexingQueueManagerSynchronously sends all instances of provided entity to indexing queue.Don't use it on a huge amount of data - all ids will be kept in memory during this process. Use
IndexingQueueManager.initAsyncEnqueueIndexAll()methods instead.- Specified by:
enqueueIndexAllin interfaceIndexingQueueManager- Parameters:
entityName- entity name- Returns:
- amount of enqueued instances
-
getEntityNamesOfEnqueueingSessions
Description copied from interface:IndexingQueueManagerGets entity names of all existing enqueueing sessions.- Specified by:
getEntityNamesOfEnqueueingSessionsin interfaceIndexingQueueManager- Returns:
- list of entity names
-
initAsyncEnqueueIndexAll
public void initAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManagerInitializes async enqueueing session for all indexed entities.- Specified by:
initAsyncEnqueueIndexAllin interfaceIndexingQueueManager
-
initAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManagerInitializes async enqueueing session for provided entity. Existing session will be removed and created again.- Specified by:
initAsyncEnqueueIndexAllin interfaceIndexingQueueManager- Parameters:
entityName- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
suspendAsyncEnqueueIndexAll
public void suspendAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManagerSuspends all enqueueing sessions. Suspended sessions are ignored during session processing. Session can be resumed byIndexingQueueManager.resumeAsyncEnqueueIndexAll()- Specified by:
suspendAsyncEnqueueIndexAllin interfaceIndexingQueueManager
-
suspendAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManagerSuspends enqueueing session for provided entity. Suspended sessions are ignored during session processing. Session can be resumed byIndexingQueueManager.resumeAsyncEnqueueIndexAll()- Specified by:
suspendAsyncEnqueueIndexAllin interfaceIndexingQueueManager- Parameters:
entityName- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
resumeAsyncEnqueueIndexAll
public void resumeAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManagerResumes all previously suspended enqueueing sessions.- Specified by:
resumeAsyncEnqueueIndexAllin interfaceIndexingQueueManager
-
resumeAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManagerResumes previously suspended enqueueing session for provided entity.- Specified by:
resumeAsyncEnqueueIndexAllin interfaceIndexingQueueManager- Parameters:
entityName- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
terminateAsyncEnqueueIndexAll
public void terminateAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManagerTerminates all enqueueing sessions.- Specified by:
terminateAsyncEnqueueIndexAllin interfaceIndexingQueueManager
-
terminateAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManagerTerminates enqueueing session for provided entity.- Specified by:
terminateAsyncEnqueueIndexAllin interfaceIndexingQueueManager- Parameters:
entityName- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
processNextEnqueueingSession
public int processNextEnqueueingSession()Description copied from interface:IndexingQueueManagerProcesses next available enqueueing session - one batch (with default size) of entity instances will be enqueued.- Specified by:
processNextEnqueueingSessionin interfaceIndexingQueueManager- Returns:
- amount of processed entity instances
-
processNextEnqueueingSession
public int processNextEnqueueingSession(int batchSize) Description copied from interface:IndexingQueueManagerProcesses next available enqueueing session - one batch (with provided size) of entity instances will be enqueued.- Specified by:
processNextEnqueueingSessionin interfaceIndexingQueueManager- Parameters:
batchSize- batch size- Returns:
- amount of processed entity instances
-
processEnqueueingSession
Description copied from interface:IndexingQueueManagerProcesses enqueueing session for provided entity - one batch (with default size) of entity instances will be enqueued.- Specified by:
processEnqueueingSessionin interfaceIndexingQueueManager- Parameters:
entityName- entity name- Returns:
- amount of processed entity instances
-
processEnqueueingSession
Description copied from interface:IndexingQueueManagerProcesses enqueueing session for provided entity - one batch (with provided size) of entity instances will be enqueued.- Specified by:
processEnqueueingSessionin interfaceIndexingQueueManager- Parameters:
entityName- entity namebatchSize- batch size- Returns:
- amount of processed entity instances
-
enqueueDelete
Description copied from interface:IndexingQueueManagerSends provided entity instance to indexing queue in order to delete it from index.- Specified by:
enqueueDeletein interfaceIndexingQueueManager- Parameters:
entityInstance- instance- Returns:
- amount of enqueued instances
-
enqueueDeleteCollection
Description copied from interface:IndexingQueueManagerSends provided entity instances to indexing queue in order to delete them from index.- Specified by:
enqueueDeleteCollectionin interfaceIndexingQueueManager- Parameters:
entityInstances- instances- Returns:
- amount of enqueued instances
-
enqueueDeleteByEntityId
Description copied from interface:IndexingQueueManagerSends entity instance to indexing queue by provided ID in order to delete it from index.- Specified by:
enqueueDeleteByEntityIdin interfaceIndexingQueueManager- Parameters:
entityId- ID of entity instance- Returns:
- amount of enqueued instances
-
enqueueDeleteCollectionByEntityIds
Description copied from interface:IndexingQueueManagerSends entity instances to indexing queue by provided IDs in order to delete them from index.- Specified by:
enqueueDeleteCollectionByEntityIdsin interfaceIndexingQueueManager- Parameters:
entityIds- IDs of entity instances- Returns:
- amount of enqueued instances
-
processNextBatch
public int processNextBatch()Description copied from interface:IndexingQueueManagerRetrieves next batch of items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processNextBatchin interfaceIndexingQueueManager- Returns:
- amount of processed queue items
-
processNextBatch
public int processNextBatch(int batchSize) Description copied from interface:IndexingQueueManagerRetrieves next batch of items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processNextBatchin interfaceIndexingQueueManager- Parameters:
batchSize- amount of queue items to process- Returns:
- amount of processed queue items
-
processEntireQueue
public int processEntireQueue()Description copied from interface:IndexingQueueManagerRetrieves items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processEntireQueuein interfaceIndexingQueueManager- Returns:
- amount of processed queue items
-
processEntireQueue
public int processEntireQueue(int batchSize) Description copied from interface:IndexingQueueManagerRetrieves items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processEntireQueuein interfaceIndexingQueueManager- Parameters:
batchSize- amount of queue items to process within single batch- Returns:
- amount of processed queue items
-
processEnqueueingSession
-
enqueueNextBatchInternal
-
enqueueIndexAll
-
loadRawIds
-
processRawIds
-
processQueue
protected int processQueue(int batchSize, boolean processEntireQueue) -
createDequeueLoadContext
protected LoadContext<IndexingQueueItem> createDequeueLoadContext(List<String> unavailableEntities, int batchSize) -
processQueueItems
-
processQueueItemsGroup
protected List<IndexingQueueItem> processQueueItemsGroup(Map<Id<?>, List<IndexingQueueItem>> itemsGroup, Function<Collection<Id<?>>, IndexResult> processingFunction) -
handleIndexResult
protected List<IndexingQueueItem> handleIndexResult(IndexResult indexResult, Map<Id<?>, List<IndexingQueueItem>> itemsGroup) -
groupQueueItems
protected Map<IndexingOperation,Map<Id<?>, groupQueueItemsList<IndexingQueueItem>>> (Collection<IndexingQueueItem> queueItems) -
enqueue
-
enqueueByIds
-
enqueue
-
createQueueItem
protected IndexingQueueItem createQueueItem(MetaClass metaClass, String entityId, IndexingOperation operation) -
createQueueItem
protected IndexingQueueItem createQueueItem(String entityName, String entityId, IndexingOperation operation)
-