public class

DefaultIndexManager

extends Object
implements IssueIndexManager
java.lang.Object
   ↳ com.atlassian.jira.issue.index.DefaultIndexManager
Known Direct Subclasses

Summary

Fields
public static final Analyzer ANALYZER_FOR_INDEXING
public static final Analyzer ANALYZER_FOR_SEARCHING
Public Constructors
DefaultIndexManager(IndexingConfiguration indexProperties, IssueIndexer issueIndexer, IndexPathManager indexPath, ReindexMessageManager reindexMessageManager, EventPublisher eventPublisher, ListenerManager listenerManager, ProjectManager projectManager, IssueManager issueManager, TaskManager taskManager, OfBizDelegator ofBizDelegator, ReplicatedIndexManager replicatedIndexManager, IssueSearcherFactory issueSearcherFactory, TimeTrackingConfiguration timeTrackingConfiguration)
Public Methods
long activate(Context context)
Activates search indexes.
long activate(Context context, boolean reindex)
Activates search indexes.
void closeQuietly(IndexSearcher issueSearcher)
void deIndex(Issue issue)
Remove an issue from the search index.
void deIndex(GenericValue entity)
Remove an issue from the search index.
void deIndexIssueObjects(Set<Issue> issuesToDelete, boolean updateReplicatedIndexStore)
Remove a set of issues from the search index.
void deactivate()
De-activates indexing (as happens from the admin page) and removes index directories.
static void flushThreadLocalSearchers()
Collection<String> getAllIndexPaths()
Analyzer getAnalyzerForIndexing()
Returns an Analyzer for indexing.
Analyzer getAnalyzerForSearching()
Returns an Analyzer for searching.
IndexSearcher getChangeHistorySearcher()
Get an IndexSearcher that can be used to search the change history index.
IndexSearcher getCommentSearcher()
Get an IndexSearcher that can be used to search the comment index.
List<String> getExistingPluginsPaths()
Returns a collection of Strings, each one representing the absolute path to the actual existing directory where a plugin keeps its indexes.
IndexSearcher getIssueSearcher()
Get an IndexSearcher that can be used to search the issue index.
String getPluginsRootPath()
Get the root path of the index directory for plugins.
IndexSearcher getWorklogSearcher()
Get an IndexSearcher that can be used to search the worklog index.
void hold()
Temporarily suspend indexing on this thread.
boolean isEmpty()
boolean isHeld()
Return true if the index is held.
boolean isIndexAvailable()
Whether this index is available.
boolean isIndexConsistent()
boolean isIndexingEnabled()
long optimize()
Optimize the underlying indexes.
void reIndex(Issue issue, IssueIndexingParams issueIndexingParams)
Reindex an issue (eg.
void reIndex(GenericValue issueGV)
Reindex an issue (eg.
void reIndex(Issue issue, boolean reIndexComments, boolean reIndexChangeHistory)
Reindex an issue (eg.
void reIndex(Issue issue)
Reindex an issue (eg.
long reIndexAll(Context context)
Reindex everything.
long reIndexAll(Context context, boolean useBackgroundIndexing, IssueIndexingParams issueIndexingParams, boolean updateReplicatedIndex)
Reindex all issues.
long reIndexAll(Context context, boolean useBackgroundIndexing, boolean updateReplicatedIndex)
Reindex all issues.
long reIndexAll()
Reindex all issues.
long reIndexAll(Context context, boolean useBackgroundIndexing)
long reIndexAll(Context context, IssueIndexingParams issueIndexingParams)
Reindex indexes defined by the IssueIndexingParams.
long reIndexAll(Context context, boolean useBackgroundIndexing, boolean reIndexComments, boolean reIndexChangeHistory, boolean updateReplicatedIndex)
Reindex all issues.
long reIndexAllIssuesInBackground(Context context)
Reindex everything, but don't stop the world Comments and change history will not be reindexed.
long reIndexAllIssuesInBackground(Context context, boolean reIndexComments, boolean reIndexChangeHistory)
Reindex everything, but don't stop the world
long reIndexComments(Collection<Comment> comments, Context context, boolean updateReplicatedIndexStore)
Reindexes a collection of comments.
long reIndexComments(Collection<Comment> comments)
Reindexes a collection of comments.
long reIndexComments(Collection<Comment> comments, Context context)
Reindexes a collection of comments.
long reIndexIssueObjects(Collection<? extends Issue> issueObjects, boolean reIndexComments, boolean reIndexChangeHistory)
Reindex a set of issues.
long reIndexIssueObjects(Collection<? extends Issue> issueObjects, boolean reIndexComments, boolean reIndexChangeHistory, boolean updateReplicatedIndexStore)
Reindex a set of issues.
long reIndexIssueObjects(Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams, boolean updateReplicatedIndexStore)
Reindex a set of issues.
long reIndexIssueObjects(Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams)
Reindex a set of issues.
long reIndexIssueObjects(Collection<? extends Issue> issueObjects)
Reindex a set of issues.
long reIndexIssues(Collection<GenericValue> issues)
Reindex a set of issues (GenericValues).
long reIndexIssues(IssuesIterable issuesIterable, Context context)
Reindex a list of issues, passing an optional event that will be set progress
long reIndexIssues(IssuesIterable issuesIterable, Context context, boolean reIndexComments, boolean reIndexChangeHistory)
Reindex a list of issues, passing an optional event that will be set progress.
long reIndexIssues(IssuesIterable issuesIterable, Context context, IssueIndexingParams issueIndexingParams)
Reindex a list of issues, passing an optional event that will be set progress.
long reIndexIssuesInBackground(Context context, IssueIndexingParams issueIndexingParams)
Reindex everything, but don't stop the world
long reIndexWorklogs(Collection<Worklog> worklogs)
Reindexes a collection of worklogs.
long reIndexWorklogs(Collection<Worklog> worklogs, Context context, boolean updateReplicatedIndexStore)
Reindexes a collection of worklogs.
long reIndexWorklogs(Collection<Worklog> worklogs, Context context)
Reindexes a collection of worklogs.
long release()
Release indexing on this thread.
void shutdown()
Shuts down the indexing manager and closes its resources (if any).
int size()
String toString()
boolean withReindexLock(Runnable runnable)
This method takes a runnable that is run under the 'stop the world' reindex lock.
Protected Methods
long reIndexIssues(Collection<GenericValue> issues, IssueIndexingParams issueIndexingParams)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.issue.index.IssueIndexManager
From interface com.atlassian.jira.issue.index.IssueIndexingService
From interface com.atlassian.jira.util.Shutdown
From interface com.atlassian.jira.util.collect.Sized
From interface com.atlassian.jira.util.index.IndexLifecycleManager

Fields

public static final Analyzer ANALYZER_FOR_INDEXING

public static final Analyzer ANALYZER_FOR_SEARCHING

Public Constructors

public DefaultIndexManager (IndexingConfiguration indexProperties, IssueIndexer issueIndexer, IndexPathManager indexPath, ReindexMessageManager reindexMessageManager, EventPublisher eventPublisher, ListenerManager listenerManager, ProjectManager projectManager, IssueManager issueManager, TaskManager taskManager, OfBizDelegator ofBizDelegator, ReplicatedIndexManager replicatedIndexManager, IssueSearcherFactory issueSearcherFactory, TimeTrackingConfiguration timeTrackingConfiguration)

Public Methods

public long activate (Context context)

Activates search indexes. This will rebuild the indexes.

Parameters
context used to report progress back to the user or to the logs. Must not be null.
Returns
  • Reindex time in ms

public long activate (Context context, boolean reindex)

Activates search indexes.

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

public void closeQuietly (IndexSearcher issueSearcher)

public void deIndex (Issue issue)

Remove an issue from the search index.

public void deIndex (GenericValue entity)

Remove an issue from the search index.

public void deIndexIssueObjects (Set<Issue> issuesToDelete, boolean updateReplicatedIndexStore)

Remove a set of issues from the search index.

public void deactivate ()

De-activates indexing (as happens from the admin page) and removes index directories.

public static void flushThreadLocalSearchers ()

public Collection<String> getAllIndexPaths ()

public Analyzer getAnalyzerForIndexing ()

Returns an Analyzer for indexing.

Returns
  • an analyzer for indexing.

public Analyzer getAnalyzerForSearching ()

Returns an Analyzer for searching.

Returns
  • an analyzer for searching

public IndexSearcher getChangeHistorySearcher ()

Get an IndexSearcher that can be used to search the change history index.

Note: This is an unmanaged IndexSearcher. You MUST call close() when you are done with it. Alternatively you should really call passing in CHANGE_HISTORY_INDEX as it is a managed searcher and all the closing semantics are handled for you.

public IndexSearcher getCommentSearcher ()

Get an IndexSearcher that can be used to search the comment index.

Note: This is an unmanaged IndexSearcher. You MUST call close() when you are done with it. Alternatively you should really call passing in COMMENT_INDEX as it is a managed searcher and all the closing semantics are handled for you.

public List<String> getExistingPluginsPaths ()

Returns a collection of Strings, each one representing the absolute path to the actual existing directory where a plugin keeps its indexes. Each directory in the collection should be a sub-directory under the plugin's index root path. See getPluginsRootPath().

If a plugin index root path does not exist, or is empty (no sub-directopries exist) then an empty collection will be returned.

public IndexSearcher getIssueSearcher ()

Get an IndexSearcher that can be used to search the issue index.

Note: This is an unmanaged IndexSearcher. You MUST call close() when you are done with it. Alternatively you should really call passing in ISSUE_INDEX as it is a managed searcher and all the closing semantics are handled for you.

public String getPluginsRootPath ()

Get the root path of the index directory for plugins. Any plugin that keeps indexes should create its own sub-directory under this path and create its indexes in its own sub-directory

public IndexSearcher getWorklogSearcher ()

Get an IndexSearcher that can be used to search the worklog index.

Note: This is an unmanaged IndexSearcher. You MUST call close() when you are done with it. Alternatively you should really call passing in WORKLOG_INDEX as it is a managed searcher and all the closing semantics are handled for you.

public void hold ()

Temporarily suspend indexing on this thread. All index requests will be queued and processed when release is called.

public boolean isEmpty ()

public boolean isHeld ()

Return true if the index is held.

public boolean isIndexAvailable ()

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.

Returns
  • Whether this index is available.

public boolean isIndexConsistent ()

public boolean isIndexingEnabled ()

public long optimize ()

Optimize the underlying indexes. Make the subsequent searching more efficient.

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.

public void reIndex (Issue issue, IssueIndexingParams issueIndexingParams)

Reindex an issue (eg. after field updates).

public void reIndex (GenericValue issueGV)

Reindex an issue (eg. after field updates).

public void reIndex (Issue issue, boolean reIndexComments, boolean reIndexChangeHistory)

Reindex an issue (eg. after field updates).

public void reIndex (Issue issue)

Reindex an issue (eg. after field updates).

public long reIndexAll (Context context)

Reindex everything.

Parameters
context used to report progress back to the user or to the logs. Must not be null.
Returns
  • Reindex time in ms.

public long reIndexAll (Context context, boolean useBackgroundIndexing, IssueIndexingParams issueIndexingParams, boolean updateReplicatedIndex)

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.

Parameters
context used to report progress back to the user or to the logs. Must not be null
useBackgroundIndexing 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.
updateReplicatedIndex whether to update the replicated index or not
Returns
  • Reindex time in ms.

public long reIndexAll (Context context, boolean useBackgroundIndexing, boolean updateReplicatedIndex)

Reindex all issues.

Parameters
context used to report progress back to the user or to the logs. Must not be null
useBackgroundIndexing whether to index in the background or not. If the useBackgroundReindexing option is set to true, then all related fields will not be reindexed.
updateReplicatedIndex whether to update the replicated index or not
Returns
  • Reindex time in ms.

public long reIndexAll ()

Reindex all issues.

Returns
  • The number of milliseconds taken to reindex everything, or -1 if not indexing

public long reIndexAll (Context context, boolean useBackgroundIndexing)

public long reIndexAll (Context context, IssueIndexingParams issueIndexingParams)

Reindex indexes defined by the IssueIndexingParams.

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.

public long reIndexAll (Context context, boolean useBackgroundIndexing, boolean reIndexComments, boolean reIndexChangeHistory, boolean updateReplicatedIndex)

Reindex all issues. If the useBackgroundReindexing option is set to true, then only the basic issue information will be reindexed, unless the reIndexComments or reIndexChangeHistory 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.

Parameters
context used to report progress back to the user or to the logs. Must not be null
useBackgroundIndexing whether to index in the background or not
reIndexComments Also reindex all the issue comments. Only relevant for background reindex operations.
reIndexChangeHistory Also reindex the issue change history. Only relevant for background reindex operations.
updateReplicatedIndex whether to update the replicated index or not
Returns
  • Reindex time in ms.

public long reIndexAllIssuesInBackground (Context context)

Reindex everything, but don't stop the world Comments and change history will not be reindexed.

Parameters
context used to report progress back to the user or to the logs. Must not be null.
Returns
  • Reindex time in ms.

public long reIndexAllIssuesInBackground (Context context, boolean reIndexComments, boolean reIndexChangeHistory)

Reindex everything, but don't stop the world

Parameters
context used to report progress back to the user or to the logs. Must not be null.
reIndexComments Also reindex all the issue comments.
reIndexChangeHistory Also reindex the issue change history.
Returns
  • Reindex time in ms.

public long reIndexComments (Collection<Comment> comments, Context context, boolean updateReplicatedIndexStore)

Reindexes a collection of comments.

Parameters
comments a collection of Comment
context used to report progress back to the user or to the logs. Must not be null.
updateReplicatedIndexStore whether to update the replicated index or not

public long reIndexComments (Collection<Comment> comments)

Reindexes a collection of comments.

Parameters
comments a collection of Comment

public long reIndexComments (Collection<Comment> comments, Context context)

Reindexes a collection of comments.

Parameters
comments a collection of Comment
context used to report progress back to the user or to the logs. Must not be null.

public long reIndexIssueObjects (Collection<? extends Issue> issueObjects, boolean reIndexComments, boolean reIndexChangeHistory)

Reindex a set of issues.

Parameters
issueObjects Set of Issues to reindex.
Returns
  • Reindex time in ms.

public long reIndexIssueObjects (Collection<? extends Issue> issueObjects, boolean reIndexComments, boolean reIndexChangeHistory, boolean updateReplicatedIndexStore)

Reindex a set of issues.

Parameters
issueObjects Set of Issues to reindex.
reIndexComments whether to reindex the comments or not
reIndexChangeHistory whether to reindex changeHistory or not
updateReplicatedIndexStore whether to store index operations in the replicated index store
Returns
  • Reindex time in ms.

public long reIndexIssueObjects (Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams, boolean updateReplicatedIndexStore)

Reindex a set of issues.

Parameters
issueObjects Set of Issues to reindex.
issueIndexingParams Determines witch related objects should be indexed together with issues.
updateReplicatedIndexStore whether to store index operations in the replicated index store
Returns
  • Reindex time in ms.

public long reIndexIssueObjects (Collection<? extends Issue> issueObjects, IssueIndexingParams issueIndexingParams)

Reindex a set of issues.

Parameters
issueObjects Set of Issues to reindex.
issueIndexingParams Determines witch related objects should be indexed together with issues.
Returns
  • Reindex time in ms.

public long reIndexIssueObjects (Collection<? extends Issue> issueObjects)

Reindex a set of issues.

Parameters
issueObjects Set of Issues to reindex.
Returns
  • Reindex time in ms.

public long reIndexIssues (Collection<GenericValue> issues)

Reindex a set of issues (GenericValues). Use reIndexIssueObjects(Collection) instead when possible.

Parameters
issues The Issue GenericValues to reindex.
Returns
  • Reindex time in ms.

public long reIndexIssues (IssuesIterable issuesIterable, Context context)

Reindex a list of issues, passing an optional event that will be set progress

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.

public long reIndexIssues (IssuesIterable issuesIterable, Context context, boolean reIndexComments, boolean reIndexChangeHistory)

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.

Parameters
issuesIterable IssuesIterable
context used to report progress back to the user or to the logs. Must not be null.
reIndexComments a boolean indicating whether to index issue comments
reIndexChangeHistory a boolean indicating whether to index issue change history
Returns
  • Reindex time in ms.

public long reIndexIssues (IssuesIterable issuesIterable, Context context, IssueIndexingParams issueIndexingParams)

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.

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.

public long reIndexIssuesInBackground (Context context, IssueIndexingParams issueIndexingParams)

Reindex everything, but don't stop the world

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.

public long reIndexWorklogs (Collection<Worklog> worklogs)

Reindexes a collection of worklogs.

Parameters
worklogs a collection of Worklogs

public long reIndexWorklogs (Collection<Worklog> worklogs, Context context, boolean updateReplicatedIndexStore)

Reindexes a collection of worklogs.

Parameters
worklogs a collection of Worklogs
context used to report progress back to the user or to the logs. Must not be null.
updateReplicatedIndexStore whether to update the replicated index or not

public long reIndexWorklogs (Collection<Worklog> worklogs, Context context)

Reindexes a collection of worklogs.

Parameters
worklogs a collection of Worklogs
context used to report progress back to the user or to the logs. Must not be null.

public long release ()

Release indexing on this thread. All queued index requests will be processed.

Returns
  • Reindex time in ms.

public void shutdown ()

Shuts down the indexing manager and closes its resources (if any).

public int size ()

public String toString ()

public boolean withReindexLock (Runnable runnable)

This method takes a runnable that is run under the 'stop the world' reindex lock. It is used here in preference to a Guava function in order to avoid introducing more Guava into the API, which limits our ability to update the library. The runnable is executed in the current thread.

Parameters
runnable The runnable to be executed
Returns
  • true if the lock was acquired and the runnable was run, false if the lock could not be acquired and the code was not run

Protected Methods

protected long reIndexIssues (Collection<GenericValue> issues, IssueIndexingParams issueIndexingParams)