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 Details

  • Method Details

    • deactivate

      public void deactivate()
      Description copied from interface: IndexLifecycleManager
      De-activates indexing (as happens from the admin page) and removes index directories.
      Specified by:
      deactivate in interface IndexLifecycleManager
    • activate

      public long activate(Context context)
      Description copied from interface: IndexLifecycleManager
      Activates search indexes. This will rebuild the indexes.
      Specified by:
      activate in interface IndexLifecycleManager
      Parameters:
      context - used to report progress back to the user or to the logs. Must not be null.
      Returns:
      Reindex time in ms
    • activate

      public long activate(Context context, boolean reindex)
      Description copied from interface: IndexLifecycleManager
      Activates search indexes.
      Specified by:
      activate in interface IndexLifecycleManager
      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: IndexLifecycleManager
      Whether 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:
      isIndexAvailable in interface IndexLifecycleManager
      Returns:
      Whether this index is available.
    • reIndexAll

      public long reIndexAll(Context context)
      Description copied from interface: IndexLifecycleManager
      Reindex everything.
      Specified by:
      reIndexAll in interface IndexLifecycleManager
      Parameters:
      context - used to report progress back to the user or to the logs. Must not be null.
      Returns:
      Reindex time in ms.
    • reIndexAll

      public long reIndexAll(Context context, IssueIndexingParams issueIndexingParams)
      Description copied from interface: IndexLifecycleManager
      Reindex indexes defined by the IssueIndexingParams.
      Specified by:
      reIndexAll in interface IndexLifecycleManager
      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

      public long reIndexAllIssuesInBackground(Context context)
      Description copied from interface: IndexLifecycleManager
      Reindex everything, but don't stop the world Comments and change history will not be reindexed.
      Specified by:
      reIndexAllIssuesInBackground in interface IndexLifecycleManager
      Parameters:
      context - used to report progress back to the user or to the logs. Must not be null.
      Returns:
      Reindex time in ms.
    • reIndexIssuesInBackground

      public long reIndexIssuesInBackground(Context context, IssueIndexingParams issueIndexingParams)
      Description copied from interface: IndexLifecycleManager
      Reindex everything, but don't stop the world
      Specified by:
      reIndexIssuesInBackground in interface IndexLifecycleManager
      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:
      isIndexConsistent in interface IndexLifecycleManager
      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 that false is also returned if the index is not available .
    • size

      public int size()
      Specified by:
      size in interface IndexLifecycleManager
      Specified by:
      size in interface Sized
      Returns:
      how many Entities will be re-indexed by IndexLifecycleManager.reIndexAll(Context)
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Sized
    • optimize

      public long optimize()
      Description copied from interface: IndexLifecycleManager
      Optimize the underlying indexes. Make the subsequent searching more efficient.
      Specified by:
      optimize in interface IndexLifecycleManager
      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

      public Collection<String> getAllIndexPaths()
      Specified by:
      getAllIndexPaths in interface IndexLifecycleManager
      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: IndexLifecycleManager
      Shuts down the indexing manager and closes its resources (if any).
      Specified by:
      shutdown in interface IndexLifecycleManager
      Specified by:
      shutdown in interface Shutdown
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • reIndexAll

      public long reIndexAll() throws IndexException
      Description copied from interface: IssueIndexingService
      Reindex all issues.
      Specified by:
      reIndexAll in interface IssueIndexingService
      Returns:
      Reindex time in ms.
      Throws:
      IndexException
    • reIndexAll

      public long reIndexAll(Context context, boolean useBackgroundReindexing, boolean notifyCluster) throws IndexException
      Description copied from interface: IssueIndexingService
      Reindex all issues.
      Specified by:
      reIndexAll in interface IssueIndexingService
      Parameters:
      context - used to report progress back to the user or to the logs. Must not be null
      useBackgroundReindexing - 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: IssueIndexingService
      Reindex 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:
      reIndexAll in interface IssueIndexingService
      Parameters:
      context - used to report progress back to the user or to the logs. Must not be null
      useBackgroundReindexing - whether to index in the background or not
      issueIndexingParams - 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

      public long reIndexIssues(IssuesIterable issuesIterable, Context context) throws IndexException
      Description copied from interface: IssueIndexingService
      Reindex a list of issues, passing an optional event that will be set progress
      Specified by:
      reIndexIssues in interface IssueIndexingService
      Parameters:
      issuesIterable - IssuesIterable
      context - 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: IssueIndexingService
      Reindex 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:
      reIndexIssues in interface IssueIndexingService
      Parameters:
      issuesIterable - IssuesIterable
      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.
      Throws:
      IndexException
    • reIndexIssues

      public long reIndexIssues(IssuesIterable issuesIterable, Context context, IssueIndexingParams issueIndexingParams, boolean shouldReplicate) throws IndexException
      Description copied from interface: IssueIndexingService
      Reindex 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:
      reIndexIssues in interface IssueIndexingService
      Parameters:
      issuesIterable - IssuesIterable of issues to reindex
      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.
      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

      public void reIndex(Issue issue) throws IndexException
      Description copied from interface: IssueIndexingService
      Reindex an issue (eg. after field updates).
      Specified by:
      reIndex in interface IssueIndexingService
      Throws:
      IndexException
    • reIndex

      public void reIndex(Issue issue, IssueIndexingParams issueIndexingParams) throws IndexException
      Description copied from interface: IssueIndexingService
      Reindex an issue (eg. after field updates).
      Specified by:
      reIndex in interface IssueIndexingService
      Throws:
      IndexException
    • reIndexIssueObjects

      public long reIndexIssueObjects(Collection<? extends Issue> issueObjects) throws IndexException
      Description copied from interface: IssueIndexingService
      Reindex a set of issues.
      Specified by:
      reIndexIssueObjects in interface IssueIndexingService
      Parameters:
      issueObjects - Set of Issues 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: IssueIndexingService
      Reindex a set of issues.
      Specified by:
      reIndexIssueObjects in interface IssueIndexingService
      Parameters:
      issueObjects - Set of Issues 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: IssueIndexingService
      Reindex a set of issues.
      Specified by:
      reIndexIssueObjects in interface IssueIndexingService
      Parameters:
      issueObjects - Set of Issues 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

      public long reIndexComments(Collection<Comment> comments)
      Description copied from interface: IssueIndexingService
      Reindexes a collection of comments.
      Specified by:
      reIndexComments in interface IssueIndexingService
      Parameters:
      comments - a collection of Comment
    • reIndexComments

      public long reIndexComments(Collection<Comment> comments, Context context)
      Description copied from interface: IssueIndexingService
      Reindexes a collection of comments.
      Specified by:
      reIndexComments in interface IssueIndexingService
      Parameters:
      comments - a collection of Comment
      context - used to report progress back to the user or to the logs. Must not be null.
    • reIndexComments

      public long reIndexComments(Collection<Comment> comments, Context context, boolean shouldReplicate)
      Description copied from interface: IssueIndexingService
      Reindexes a collection of comments.
      Specified by:
      reIndexComments in interface IssueIndexingService
      Parameters:
      comments - a collection of Comment
      context - 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

      public long reIndexWorklogs(Collection<Worklog> worklogs)
      Description copied from interface: IssueIndexingService
      Reindexes a collection of worklogs.
      Specified by:
      reIndexWorklogs in interface IssueIndexingService
      Parameters:
      worklogs - a collection of Worklogs
    • reIndexWorklogs

      public long reIndexWorklogs(Collection<Worklog> worklogs, Context context)
      Description copied from interface: IssueIndexingService
      Reindexes a collection of worklogs.
      Specified by:
      reIndexWorklogs in interface IssueIndexingService
      Parameters:
      worklogs - a collection of Worklogs
      context - used to report progress back to the user or to the logs. Must not be null.
    • reIndexWorklogs

      public long reIndexWorklogs(Collection<Worklog> worklogs, Context context, boolean shouldReplicate)
      Description copied from interface: IssueIndexingService
      Reindexes a collection of worklogs.
      Specified by:
      reIndexWorklogs in interface IssueIndexingService
      Parameters:
      worklogs - a collection of Worklogs
      context - 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

      public void deIndex(WithId issueWithId) throws IndexException
      Description copied from interface: IssueIndexingService
      Remove an issue from the search index.
      Specified by:
      deIndex in interface IssueIndexingService
      Throws:
      IndexException
    • deIndexIssueObjectsById

      public void deIndexIssueObjectsById(Set<? extends WithId> issuesToDelete, boolean shouldReplicate) throws IndexException
      Description copied from interface: IssueIndexingService
      Remove a set of issues from the search index.
      Specified by:
      deIndexIssueObjectsById in interface IssueIndexingService
      Parameters:
      issuesToDelete - set of WithIds to deIndex.
      shouldReplicate - whether or not the index changes should be replicated to the other nodes in the cluster.
      Throws:
      IndexException
    • deIndex

      public void deIndex(Project project, boolean shouldReplicate)
      Description copied from interface: IssueIndexingService
      Deindexing issues from a given project
      Specified by:
      deIndex in interface IssueIndexingService
      Parameters:
      project - project object
      shouldReplicate - whether or not the index changes should be replicated to the other nodes in the cluster.
    • deIndexComments

      public void deIndexComments(Set<WithId> commentsToDelete, boolean shouldReplicate)
      Description copied from interface: IssueIndexingService
      Remove a set of comments from the search index.
      Specified by:
      deIndexComments in interface IssueIndexingService
      Parameters:
      commentsToDelete - set of WithIds to deIndex.
      shouldReplicate - whether or not the index changes should be replicated to the other nodes in the cluster.
    • deIndexWorklogs

      public void deIndexWorklogs(Set<WithId> worklogsToDelete, boolean shouldReplicate)
      Description copied from interface: IssueIndexingService
      Remove a set of worklogs from the search index.
      Specified by:
      deIndexWorklogs in interface IssueIndexingService
      Parameters:
      worklogsToDelete - set of WithIds 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: IssueIndexingService
      Temporarily suspend indexing on this thread. All index requests will be queued and processed when release is called.
      Specified by:
      hold in interface IssueIndexingService
    • isHeld

      public boolean isHeld()
      Description copied from interface: IssueIndexingService
      Return true if the index is held on this thread.
      Specified by:
      isHeld in interface IssueIndexingService
    • release

      public long release() throws IndexException
      Description copied from interface: IssueIndexingService
      Release indexing on this thread. All queued index requests will be processed.
      Specified by:
      release in interface IssueIndexingService
      Returns:
      Reindex time in ms.
      Throws:
      IndexException - if an error occurs
    • getLatestIndexDate

      @Nullable public Instant getLatestIndexDate()
      Description copied from interface: IssueIndexingService
      Gets the latest index date based on the most recent issue updated date.
      Specified by:
      getLatestIndexDate in interface IssueIndexingService
      Returns:
      latest index update date or null if no issues in index or no updated value in issues