Class OpenSearchIssueIndexManager
java.lang.Object
com.atlassian.jira.search.opensearch.OpenSearchIssueIndexManager
- All Implemented Interfaces:
IssueIndexingService,Sized,IndexLifecycleManager,Shutdown
- Direct Known Subclasses:
OpenSearchJiraIndexManager
public class OpenSearchIssueIndexManager
extends Object
implements IndexLifecycleManager, IssueIndexingService
OpenSearch implementation of the IssueIndexingService and IndexLifecycleManager.
This class manages the lifecycle of the issue index, including activation, deactivation, reindexing, and optimization.
It also provides methods for indexing and de-indexing issues, comments, and worklogs.
See
IndexManagerBase for the Lucene equivalent- Since:
- v11.0
-
Constructor Summary
ConstructorsConstructorDescriptionOpenSearchIssueIndexManager(IndexingConfiguration indexProperties, IssueIndexer issueIndexer, ReindexMessageManager reindexMessageManager, com.atlassian.event.api.EventPublisher eventPublisher, ListenerManager listenerManager, IssueManager issueManager, ArchivingDao archivingDao, IndexingLanguageSetting indexingLanguageSetting, ReindexingAuditHandler reindexingAuditHandler, IndexConsistencyChecker indexConsistencyChecker, ReindexStrategy reindexStrategy, OpenSearchConfigManager openSearchConfigManager) -
Method Summary
Modifier and TypeMethodDescriptionlongActivates search indexes.longActivates search indexes.voidDe-activates indexing (as happens from the admin page) and removes index directories.voidRemove an issue from the search index.voidDeindexing issues from a given projectvoiddeIndexComments(Set<WithId> commentsToDelete, boolean shouldReplicate) Remove a set of comments from the search index.voiddeIndexIssueObjectsById(Set<? extends WithId> issuesToDelete, boolean shouldReplicate) Remove a set of issues from the search index.voiddeIndexWorklogs(Set<WithId> worklogsToDelete, boolean shouldReplicate) Remove a set of worklogs from the search index.Gets the latest index date based on the most recent issue updated date.voidhold()Temporarily suspend indexing on this thread.booleanisEmpty()booleanisHeld()Return true if the index is held on this thread.booleanWhether this index is available.booleanlongoptimize()Optimize the underlying indexes.voidReindex an issue (eg.voidreIndex(Issue issue, IssueIndexingParams issueIndexingParams) Reindex an issue (eg.longReindex all issues.longreIndexAll(Context context) Reindex everything.longreIndexAll(Context context, boolean useBackgroundReindexing, boolean notifyCluster) Reindex all issues.longreIndexAll(Context context, boolean useBackgroundReindexing, IssueIndexingParams issueIndexingParams, boolean notifyCluster) Reindex all issues.longreIndexAll(Context context, IssueIndexingParams issueIndexingParams) Reindex indexes defined by theIssueIndexingParams.longreIndexAllIssuesInBackground(Context context) Reindex everything, but don't stop the world Comments and change history will not be reindexed.longreIndexComments(Collection<Comment> comments) Reindexes a collection of comments.longreIndexComments(Collection<Comment> comments, Context context) Reindexes a collection of comments.longreIndexComments(Collection<Comment> comments, Context context, boolean shouldReplicate) Reindexes a collection of comments.longreIndexIssueObjects(Collection<? extends Issue> issueObjects) Reindex a set of issues.longreIndexIssueObjects(Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams) Reindex a set of issues.longreIndexIssueObjects(Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams, boolean shouldReplicate) Reindex a set of issues.longreIndexIssues(IssuesIterable issuesIterable, Context context) Reindex a list of issues, passing an optional event that will be set progresslongreIndexIssues(IssuesIterable issuesIterable, Context context, IssueIndexingParams issueIndexingParams) Reindex a list of issues, passing an optional event that will be set progress.longreIndexIssues(IssuesIterable issuesIterable, Context context, IssueIndexingParams issueIndexingParams, boolean shouldReplicate) Reindex a list of issues, passing an optional Context for providing status updates.longreIndexIssuesInBackground(Context context, IssueIndexingParams issueIndexingParams) Reindex everything, but don't stop the worldlongreIndexWorklogs(Collection<Worklog> worklogs) Reindexes a collection of worklogs.longreIndexWorklogs(Collection<Worklog> worklogs, Context context) Reindexes a collection of worklogs.longreIndexWorklogs(Collection<Worklog> worklogs, Context context, boolean shouldReplicate) Reindexes a collection of worklogs.longrelease()Release indexing on this thread.voidshutdown()Shuts down the indexing manager and closes its resources (if any).intsize()toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.atlassian.jira.issue.index.IssueIndexingService
deIndex, deIndexIssueObjects
-
Constructor Details
-
OpenSearchIssueIndexManager
public OpenSearchIssueIndexManager(IndexingConfiguration indexProperties, IssueIndexer issueIndexer, ReindexMessageManager reindexMessageManager, com.atlassian.event.api.EventPublisher eventPublisher, ListenerManager listenerManager, IssueManager issueManager, ArchivingDao archivingDao, IndexingLanguageSetting indexingLanguageSetting, ReindexingAuditHandler reindexingAuditHandler, IndexConsistencyChecker indexConsistencyChecker, ReindexStrategy reindexStrategy, OpenSearchConfigManager openSearchConfigManager)
-
-
Method Details
-
deactivate
public void deactivate()Description copied from interface:IndexLifecycleManagerDe-activates indexing (as happens from the admin page) and removes index directories.- Specified by:
deactivatein interfaceIndexLifecycleManager
-
activate
Description copied from interface:IndexLifecycleManagerActivates search indexes. This will rebuild the indexes.- Specified by:
activatein interfaceIndexLifecycleManager- Parameters:
context- used to report progress back to the user or to the logs. Must not be null.- Returns:
- Reindex time in ms
-
activate
Description copied from interface:IndexLifecycleManagerActivates search indexes.- Specified by:
activatein interfaceIndexLifecycleManager- Parameters:
context- used to report progress back to the user or to the logs. Must not be null.reindex- reindex after activation.- Returns:
- Reindex time in ms
-
isIndexAvailable
public boolean isIndexAvailable()Description copied from interface:IndexLifecycleManagerWhether this index is available. The index is not available if the index is being rebuilt or recovered. In a clustered environment this reflects only the state on the local node.- Specified by:
isIndexAvailablein interfaceIndexLifecycleManager- Returns:
- Whether this index is available.
-
reIndexAll
Description copied from interface:IndexLifecycleManagerReindex everything.- Specified by:
reIndexAllin interfaceIndexLifecycleManager- Parameters:
context- used to report progress back to the user or to the logs. Must not be null.- Returns:
- Reindex time in ms.
-
reIndexAll
Description copied from interface:IndexLifecycleManagerReindex indexes defined by theIssueIndexingParams.- Specified by:
reIndexAllin interfaceIndexLifecycleManager- Parameters:
context- used to report progress back to the user or to the logs. Must not be null.issueIndexingParams- indexes to reindex.- Returns:
- Reindex time in ms.
-
reIndexAllIssuesInBackground
Description copied from interface:IndexLifecycleManagerReindex everything, but don't stop the world Comments and change history will not be reindexed.- Specified by:
reIndexAllIssuesInBackgroundin interfaceIndexLifecycleManager- Parameters:
context- used to report progress back to the user or to the logs. Must not be null.- Returns:
- Reindex time in ms.
-
reIndexIssuesInBackground
Description copied from interface:IndexLifecycleManagerReindex everything, but don't stop the world- Specified by:
reIndexIssuesInBackgroundin interfaceIndexLifecycleManager- Parameters:
context- used to report progress back to the user or to the logs. Must not be null.issueIndexingParams- determines witch related objects should be indexed together with issue.- Returns:
- Reindex time in ms.
-
isIndexConsistent
public boolean isIndexConsistent()- Specified by:
isIndexConsistentin interfaceIndexLifecycleManager- Returns:
- the result of a simple consistency check that compares the index state to
the current number of issues in the database. A background re-index should not be attempted
when this returns
false. Note thatfalseis also returned if the index is not available .
-
size
public int size()- Specified by:
sizein interfaceIndexLifecycleManager- Specified by:
sizein interfaceSized- Returns:
- how many Entities will be re-indexed by
IndexLifecycleManager.reIndexAll(Context)
-
isEmpty
public boolean isEmpty() -
optimize
public long optimize()Description copied from interface:IndexLifecycleManagerOptimize the underlying indexes. Make the subsequent searching more efficient.- Specified by:
optimizein interfaceIndexLifecycleManager- Returns:
- the amount of time in millis this method took (because you are too lazy to time me), 0 if indexing is not enabled or -1 if we cannot obtain the index writeLock.
-
getAllIndexPaths
- Specified by:
getAllIndexPathsin interfaceIndexLifecycleManager- Returns:
- a collection of Strings that map to all paths that contain Lucene indexes. Must not be null.
It's Lucene specific, no longer relevant for OpenSearch. No replacement.
Platform-specific method intended for the Lucene search platform only.
Jira Search exposes a common API backed by multiple search engines. This method bypasses that abstraction and couples callers to Lucene internals.
Using this method in platform-agnostic code, or when the runtime search platform is not Lucene (e.g. OpenSearch), may produce incorrect results or failures. Internal use only.
-
shutdown
public void shutdown()Description copied from interface:IndexLifecycleManagerShuts down the indexing manager and closes its resources (if any).- Specified by:
shutdownin interfaceIndexLifecycleManager- Specified by:
shutdownin interfaceShutdown
-
toString
-
reIndexAll
Description copied from interface:IssueIndexingServiceReindex all issues.- Specified by:
reIndexAllin interfaceIssueIndexingService- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexAll
public long reIndexAll(Context context, boolean useBackgroundReindexing, boolean notifyCluster) throws IndexException Description copied from interface:IssueIndexingServiceReindex all issues.- Specified by:
reIndexAllin interfaceIssueIndexingService- Parameters:
context- used to report progress back to the user or to the logs. Must not be nulluseBackgroundReindexing- whether to index in the background or not. If the useBackgroundReindexing option is set to true, then all related fields will not be reindexed.notifyCluster- whether or not to notify the cluster about reindexing all- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexAll
public long reIndexAll(Context context, boolean useBackgroundReindexing, IssueIndexingParams issueIndexingParams, boolean notifyCluster) throws IndexException Description copied from interface:IssueIndexingServiceReindex all issues. If the useBackgroundReindexing option is set to true, then only the basic issue information will be reindexed, unless the indexing parameters are also set. This is considered the normal mode for background re-indexing and is sufficient to correct the index for changes in the system configuration, but not for changes to the indexing language. If useBackgroundReindexing is set to false, than everything is always reindexed.- Specified by:
reIndexAllin interfaceIssueIndexingService- Parameters:
context- used to report progress back to the user or to the logs. Must not be nulluseBackgroundReindexing- whether to index in the background or notissueIndexingParams- determines witch related objects should be indexed together with issues. Only relevant for background reindex operations.notifyCluster- whether or not to notify the cluster about reindexing all- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexIssues
Description copied from interface:IssueIndexingServiceReindex a list of issues, passing an optional event that will be set progress- Specified by:
reIndexIssuesin interfaceIssueIndexingService- Parameters:
issuesIterable- IssuesIterablecontext- used to report progress back to the user or to the logs. Must not be null.- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexIssues
public long reIndexIssues(IssuesIterable issuesIterable, Context context, IssueIndexingParams issueIndexingParams) throws IndexException Description copied from interface:IssueIndexingServiceReindex a list of issues, passing an optional event that will be set progress. This method can optionally also index the comments and change history.- Specified by:
reIndexIssuesin interfaceIssueIndexingService- Parameters:
issuesIterable- IssuesIterablecontext- used to report progress back to the user or to the logs. Must not be null.issueIndexingParams- determines witch related objects should be indexed together with issue.- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexIssues
public long reIndexIssues(IssuesIterable issuesIterable, Context context, IssueIndexingParams issueIndexingParams, boolean shouldReplicate) throws IndexException Description copied from interface:IssueIndexingServiceReindex a list of issues, passing an optional Context for providing status updates. This method can optionally also index the comments and change history. It also allows the caller to specify whether or not the indexing changes should be replicated to the rest of the cluster.- Specified by:
reIndexIssuesin interfaceIssueIndexingService- Parameters:
issuesIterable- IssuesIterable of issues to reindexcontext- used to report progress back to the user or to the logs. Must not be null.issueIndexingParams- determines witch related objects should be indexed together with issue.shouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.- Returns:
- Reindex time in ms, -1 if there's an error.
- Throws:
IndexException
-
reIndex
Description copied from interface:IssueIndexingServiceReindex an issue (eg. after field updates).- Specified by:
reIndexin interfaceIssueIndexingService- Throws:
IndexException
-
reIndex
Description copied from interface:IssueIndexingServiceReindex an issue (eg. after field updates).- Specified by:
reIndexin interfaceIssueIndexingService- Throws:
IndexException
-
reIndexIssueObjects
Description copied from interface:IssueIndexingServiceReindex a set of issues.- Specified by:
reIndexIssueObjectsin interfaceIssueIndexingService- Parameters:
issueObjects- Set ofIssues to reindex.- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexIssueObjects
public long reIndexIssueObjects(Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams) throws IndexException Description copied from interface:IssueIndexingServiceReindex a set of issues.- Specified by:
reIndexIssueObjectsin interfaceIssueIndexingService- Parameters:
issueObjects- Set ofIssues to reindex.issueIndexingParams- Determines witch related objects should be indexed together with issues.- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexIssueObjects
public long reIndexIssueObjects(Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams, boolean shouldReplicate) throws IndexException Description copied from interface:IssueIndexingServiceReindex a set of issues.- Specified by:
reIndexIssueObjectsin interfaceIssueIndexingService- Parameters:
issueObjects- Set ofIssues to reindex.issueIndexingParams- Determines witch related objects should be indexed together with issues.shouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.- Returns:
- Reindex time in ms.
- Throws:
IndexException
-
reIndexComments
Description copied from interface:IssueIndexingServiceReindexes a collection of comments.- Specified by:
reIndexCommentsin interfaceIssueIndexingService- Parameters:
comments- a collection of Comment
-
reIndexComments
Description copied from interface:IssueIndexingServiceReindexes a collection of comments.- Specified by:
reIndexCommentsin interfaceIssueIndexingService- Parameters:
comments- a collection of Commentcontext- used to report progress back to the user or to the logs. Must not be null.
-
reIndexComments
Description copied from interface:IssueIndexingServiceReindexes a collection of comments.- Specified by:
reIndexCommentsin interfaceIssueIndexingService- Parameters:
comments- a collection of Commentcontext- used to report progress back to the user or to the logs. Must not be null.shouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.
-
reIndexWorklogs
Description copied from interface:IssueIndexingServiceReindexes a collection of worklogs.- Specified by:
reIndexWorklogsin interfaceIssueIndexingService- Parameters:
worklogs- a collection of Worklogs
-
reIndexWorklogs
Description copied from interface:IssueIndexingServiceReindexes a collection of worklogs.- Specified by:
reIndexWorklogsin interfaceIssueIndexingService- Parameters:
worklogs- a collection of Worklogscontext- used to report progress back to the user or to the logs. Must not be null.
-
reIndexWorklogs
Description copied from interface:IssueIndexingServiceReindexes a collection of worklogs.- Specified by:
reIndexWorklogsin interfaceIssueIndexingService- Parameters:
worklogs- a collection of Worklogscontext- used to report progress back to the user or to the logs. Must not be null.shouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.
-
deIndex
Description copied from interface:IssueIndexingServiceRemove an issue from the search index.- Specified by:
deIndexin interfaceIssueIndexingService- Throws:
IndexException
-
deIndexIssueObjectsById
public void deIndexIssueObjectsById(Set<? extends WithId> issuesToDelete, boolean shouldReplicate) throws IndexException Description copied from interface:IssueIndexingServiceRemove a set of issues from the search index.- Specified by:
deIndexIssueObjectsByIdin interfaceIssueIndexingService- Parameters:
issuesToDelete- set ofWithIds to deIndex.shouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.- Throws:
IndexException
-
deIndex
Description copied from interface:IssueIndexingServiceDeindexing issues from a given project- Specified by:
deIndexin interfaceIssueIndexingService- Parameters:
project- project objectshouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.
-
deIndexComments
Description copied from interface:IssueIndexingServiceRemove a set of comments from the search index.- Specified by:
deIndexCommentsin interfaceIssueIndexingService- Parameters:
commentsToDelete- set ofWithIds to deIndex.shouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.
-
deIndexWorklogs
Description copied from interface:IssueIndexingServiceRemove a set of worklogs from the search index.- Specified by:
deIndexWorklogsin interfaceIssueIndexingService- Parameters:
worklogsToDelete- set ofWithIds to deIndex.shouldReplicate- whether or not the index changes should be replicated to the other nodes in the cluster.
-
hold
public void hold()Description copied from interface:IssueIndexingServiceTemporarily suspend indexing on this thread. All index requests will be queued and processed when release is called.- Specified by:
holdin interfaceIssueIndexingService
-
isHeld
public boolean isHeld()Description copied from interface:IssueIndexingServiceReturn true if the index is held on this thread.- Specified by:
isHeldin interfaceIssueIndexingService
-
release
Description copied from interface:IssueIndexingServiceRelease indexing on this thread. All queued index requests will be processed.- Specified by:
releasein interfaceIssueIndexingService- Returns:
- Reindex time in ms.
- Throws:
IndexException- if an error occurs
-
getLatestIndexDate
Description copied from interface:IssueIndexingServiceGets the latest index date based on the most recent issue updated date.- Specified by:
getLatestIndexDatein interfaceIssueIndexingService- Returns:
- latest index update date or null if no issues in index or no updated value in issues
-