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
Modifier and TypeClassDescriptionprotected class
Analyzes collection ofIndexingQueueItem
, determines unique entity ids and splits them among two disjoint groups: for index and for delete. -
Field Summary
Modifier and TypeFieldDescriptionprotected SystemAuthenticator
protected UnconstrainedDataManager
protected EnqueueingSessionManager
protected EntityIdsLoaderProvider
protected EntityIndexer
protected IdSerialization
protected IndexConfigurationManager
protected IndexStateRegistry
protected IndexingLocker
protected Metadata
protected MetadataTools
protected SearchProperties
protected StoreAwareLocator
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected LoadContext<IndexingQueueItem>
createDequeueLoadContext
(List<String> unavailableEntities, int batchSize) protected IndexingQueueItem
createQueueItem
(MetaClass metaClass, String entityId, IndexingOperation operation) protected IndexingQueueItem
createQueueItem
(String entityName, String entityId, IndexingOperation operation) int
Removes all queue items.int
emptyQueue
(String entityName) Removes all queue items related to provided entity.protected int
enqueue
(Collection<IndexingQueueItem> queueItems) protected int
enqueue
(Collection<Object> entityInstances, IndexingOperation operation) protected int
enqueueByIds
(Collection<Id<?>> entityIds, IndexingOperation operation) int
enqueueDelete
(Object entityInstance) Sends provided entity instance to indexing queue in order to delete it from index.int
enqueueDeleteByEntityId
(Id<?> entityId) Sends entity instance to indexing queue by provided ID in order to delete it from index.int
enqueueDeleteCollection
(Collection<Object> entityInstances) Sends provided entity instances to indexing queue in order to delete them from index.int
enqueueDeleteCollectionByEntityIds
(Collection<Id<?>> entityIds) Sends entity instances to indexing queue by provided IDs in order to delete them from index.int
enqueueIndex
(Object entityInstance) Sends provided entity instance to indexing queue in order to store it to index.int
Synchronously sends all instances of all index-configured entities to indexing queue.int
enqueueIndexAll
(String entityName) Synchronously sends all instances of provided entity to indexing queue.protected int
enqueueIndexAll
(String entityName, int batchSize) int
enqueueIndexByEntityId
(Id<?> entityId) Sends entity instance to indexing queue by provided ID in order to store it to index.int
enqueueIndexCollection
(Collection<Object> entityInstances) Sends provided entity instances to indexing queue in order to store them to index.int
enqueueIndexCollectionByEntityIds
(Collection<Id<?>> entityIds) Sends entity instances to indexing queue by provided IDs in order to store them to index.protected int
enqueueNextBatchInternal
(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) void
Initializes async enqueueing session for all indexed entities.boolean
initAsyncEnqueueIndexAll
(String entityName) Initializes async enqueueing session for provided entity.protected List<?>
loadRawIds
(MetaClass metaClass) protected int
processEnqueueingSession
(EnqueueingSession session, int batchSize) int
processEnqueueingSession
(String entityName) Processes enqueueing session for provided entity - one batch (with default size) of entity instances will be enqueued.int
processEnqueueingSession
(String entityName, int batchSize) Processes enqueueing session for provided entity - one batch (with provided size) of entity instances will be enqueued.int
Retrieves items from indexing queue and processes them - store/remove related documents in index.int
processEntireQueue
(int batchSize) Retrieves items from indexing queue and processes them - store/remove related documents in index.int
Retrieves next batch of items from indexing queue and processes them - store/remove related documents in index.int
processNextBatch
(int batchSize) Retrieves next batch of items from indexing queue and processes them - store/remove related documents in index.int
Processes next available enqueueing session - one batch (with default size) of entity instances will be enqueued.int
processNextEnqueueingSession
(int batchSize) Processes next available enqueueing session - one batch (with provided size) of entity instances will be enqueued.protected int
processQueue
(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 int
processRawIds
(List<?> rawIds, MetaClass metaClass, int batchSize) void
Resumes all previously suspended enqueueing sessions.boolean
resumeAsyncEnqueueIndexAll
(String entityName) Resumes previously suspended enqueueing session for provided entity.void
Suspends all enqueueing sessions.boolean
suspendAsyncEnqueueIndexAll
(String entityName) Suspends enqueueing session for provided entity.void
Terminates all enqueueing sessions.boolean
terminateAsyncEnqueueIndexAll
(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:IndexingQueueManager
Removes all queue items.- Specified by:
emptyQueue
in interfaceIndexingQueueManager
- Returns:
- amount of deleted items
-
emptyQueue
Description copied from interface:IndexingQueueManager
Removes all queue items related to provided entity.- Specified by:
emptyQueue
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity- Returns:
- amount of deleted items
-
enqueueIndex
Description copied from interface:IndexingQueueManager
Sends provided entity instance to indexing queue in order to store it to index.- Specified by:
enqueueIndex
in interfaceIndexingQueueManager
- Parameters:
entityInstance
- instance- Returns:
- amount of enqueued instances
-
enqueueIndexCollection
Description copied from interface:IndexingQueueManager
Sends provided entity instances to indexing queue in order to store them to index.- Specified by:
enqueueIndexCollection
in interfaceIndexingQueueManager
- Parameters:
entityInstances
- instances- Returns:
- amount of enqueued instances
-
enqueueIndexByEntityId
Description copied from interface:IndexingQueueManager
Sends entity instance to indexing queue by provided ID in order to store it to index.- Specified by:
enqueueIndexByEntityId
in interfaceIndexingQueueManager
- Parameters:
entityId
- ID of entity instance- Returns:
- amount of enqueued instances
-
enqueueIndexCollectionByEntityIds
Description copied from interface:IndexingQueueManager
Sends entity instances to indexing queue by provided IDs in order to store them to index.- Specified by:
enqueueIndexCollectionByEntityIds
in interfaceIndexingQueueManager
- Parameters:
entityIds
- IDs of entity instances- Returns:
- amount of enqueued instances
-
enqueueIndexAll
public int enqueueIndexAll()Description copied from interface:IndexingQueueManager
Synchronously 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:
enqueueIndexAll
in interfaceIndexingQueueManager
- Returns:
- amount of enqueued instances
-
enqueueIndexAll
Description copied from interface:IndexingQueueManager
Synchronously 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:
enqueueIndexAll
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity name- Returns:
- amount of enqueued instances
-
getEntityNamesOfEnqueueingSessions
Description copied from interface:IndexingQueueManager
Gets entity names of all existing enqueueing sessions.- Specified by:
getEntityNamesOfEnqueueingSessions
in interfaceIndexingQueueManager
- Returns:
- list of entity names
-
initAsyncEnqueueIndexAll
public void initAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManager
Initializes async enqueueing session for all indexed entities.- Specified by:
initAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
-
initAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManager
Initializes async enqueueing session for provided entity. Existing session will be removed and created again.- Specified by:
initAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
suspendAsyncEnqueueIndexAll
public void suspendAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManager
Suspends all enqueueing sessions. Suspended sessions are ignored during session processing. Session can be resumed byIndexingQueueManager.resumeAsyncEnqueueIndexAll()
- Specified by:
suspendAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
-
suspendAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManager
Suspends enqueueing session for provided entity. Suspended sessions are ignored during session processing. Session can be resumed byIndexingQueueManager.resumeAsyncEnqueueIndexAll()
- Specified by:
suspendAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
resumeAsyncEnqueueIndexAll
public void resumeAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManager
Resumes all previously suspended enqueueing sessions.- Specified by:
resumeAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
-
resumeAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManager
Resumes previously suspended enqueueing session for provided entity.- Specified by:
resumeAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
terminateAsyncEnqueueIndexAll
public void terminateAsyncEnqueueIndexAll()Description copied from interface:IndexingQueueManager
Terminates all enqueueing sessions.- Specified by:
terminateAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
-
terminateAsyncEnqueueIndexAll
Description copied from interface:IndexingQueueManager
Terminates enqueueing session for provided entity.- Specified by:
terminateAsyncEnqueueIndexAll
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity name- Returns:
- true if operation was successfully performed, false otherwise
-
processNextEnqueueingSession
public int processNextEnqueueingSession()Description copied from interface:IndexingQueueManager
Processes next available enqueueing session - one batch (with default size) of entity instances will be enqueued.- Specified by:
processNextEnqueueingSession
in interfaceIndexingQueueManager
- Returns:
- amount of processed entity instances
-
processNextEnqueueingSession
public int processNextEnqueueingSession(int batchSize) Description copied from interface:IndexingQueueManager
Processes next available enqueueing session - one batch (with provided size) of entity instances will be enqueued.- Specified by:
processNextEnqueueingSession
in interfaceIndexingQueueManager
- Parameters:
batchSize
- batch size- Returns:
- amount of processed entity instances
-
processEnqueueingSession
Description copied from interface:IndexingQueueManager
Processes enqueueing session for provided entity - one batch (with default size) of entity instances will be enqueued.- Specified by:
processEnqueueingSession
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity name- Returns:
- amount of processed entity instances
-
processEnqueueingSession
Description copied from interface:IndexingQueueManager
Processes enqueueing session for provided entity - one batch (with provided size) of entity instances will be enqueued.- Specified by:
processEnqueueingSession
in interfaceIndexingQueueManager
- Parameters:
entityName
- entity namebatchSize
- batch size- Returns:
- amount of processed entity instances
-
enqueueDelete
Description copied from interface:IndexingQueueManager
Sends provided entity instance to indexing queue in order to delete it from index.- Specified by:
enqueueDelete
in interfaceIndexingQueueManager
- Parameters:
entityInstance
- instance- Returns:
- amount of enqueued instances
-
enqueueDeleteCollection
Description copied from interface:IndexingQueueManager
Sends provided entity instances to indexing queue in order to delete them from index.- Specified by:
enqueueDeleteCollection
in interfaceIndexingQueueManager
- Parameters:
entityInstances
- instances- Returns:
- amount of enqueued instances
-
enqueueDeleteByEntityId
Description copied from interface:IndexingQueueManager
Sends entity instance to indexing queue by provided ID in order to delete it from index.- Specified by:
enqueueDeleteByEntityId
in interfaceIndexingQueueManager
- Parameters:
entityId
- ID of entity instance- Returns:
- amount of enqueued instances
-
enqueueDeleteCollectionByEntityIds
Description copied from interface:IndexingQueueManager
Sends entity instances to indexing queue by provided IDs in order to delete them from index.- Specified by:
enqueueDeleteCollectionByEntityIds
in interfaceIndexingQueueManager
- Parameters:
entityIds
- IDs of entity instances- Returns:
- amount of enqueued instances
-
processNextBatch
public int processNextBatch()Description copied from interface:IndexingQueueManager
Retrieves next batch of items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processNextBatch
in interfaceIndexingQueueManager
- Returns:
- amount of processed queue items
-
processNextBatch
public int processNextBatch(int batchSize) Description copied from interface:IndexingQueueManager
Retrieves next batch of items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processNextBatch
in interfaceIndexingQueueManager
- Parameters:
batchSize
- amount of queue items to process- Returns:
- amount of processed queue items
-
processEntireQueue
public int processEntireQueue()Description copied from interface:IndexingQueueManager
Retrieves items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processEntireQueue
in interfaceIndexingQueueManager
- Returns:
- amount of processed queue items
-
processEntireQueue
public int processEntireQueue(int batchSize) Description copied from interface:IndexingQueueManager
Retrieves items from indexing queue and processes them - store/remove related documents in index.- Specified by:
processEntireQueue
in 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)
-