com.atlassian.jira.issue.index
Class DefaultIndexManager

java.lang.Object
  extended by com.atlassian.jira.issue.index.DefaultIndexManager
All Implemented Interfaces:
IssueIndexManager, Sized, IndexLifecycleManager, Shutdown
Direct Known Subclasses:
BulkOnlyIndexManager, MemoryIndexManager

public class DefaultIndexManager
extends Object
implements IssueIndexManager


Field Summary
static org.apache.lucene.analysis.Analyzer ANALYZER_FOR_INDEXING
           
static org.apache.lucene.analysis.Analyzer ANALYZER_FOR_SEARCHING
           
 
Fields inherited from interface com.atlassian.jira.issue.index.IssueIndexManager
LUCENE_VERSION
 
Constructor Summary
DefaultIndexManager(IndexingConfiguration indexProperties, IssueIndexer issueIndexer, IndexPathManager indexPath, ReindexMessageManager reindexMessageManager, com.atlassian.event.api.EventPublisher eventPublisher, ListenerManager listenerManager, ProjectManager projectManager, IssueManager issueManager, TaskManager taskManager, OfBizDelegator ofBizDelegator, ReplicatedIndexManager replicatedIndexManager)
           
 
Method Summary
 long activate(Context context)
          Activates search indexes.
 long activate(Context context, boolean reindex)
          Activates search indexes.
 void deactivate()
          De-activates indexing (as happens from the admin page) and removes index directories.
 void deIndex(org.ofbiz.core.entity.GenericValue entity)
          Remove an issue from the search index.
 void deIndex(Issue issue)
          Remove an issue from the search index.
 void deIndexIssueObjects(Set<Issue> issuesToDelete, boolean updateReplicatedIndexStore)
          Remove a set of issues from the search index.
static void flushThreadLocalSearchers()
           
 Collection<String> getAllIndexPaths()
           
 org.apache.lucene.analysis.Analyzer getAnalyzerForIndexing()
          Returns an Analyzer for indexing.
 org.apache.lucene.analysis.Analyzer getAnalyzerForSearching()
          Returns an Analyzer for searching.
 org.apache.lucene.search.IndexSearcher getChangeHistorySearcher()
          Get an IndexSearcher that can be used to search the change history index.
 org.apache.lucene.search.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.
 org.apache.lucene.search.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.
 void hold()
          Temporarily suspend indexing on this thread.
 boolean isEmpty()
           
 boolean isHeld()
          Return true if the index is held.
 boolean isIndexConsistent()
           
 boolean isIndexingEnabled()
           
 long optimize()
          Optimize the underlying indexes.
 void reIndex(org.ofbiz.core.entity.GenericValue issueGV)
          Reindex an issue (eg.
 void reIndex(Issue issue)
          Reindex an issue (eg.
 void reIndex(Issue issue, boolean reIndexComments, boolean reIndexChangeHistory)
          Reindex an issue (eg.
 long reIndexAll()
          Reindex all issues.
 long reIndexAll(Context context)
          Reindex everything.
 long reIndexAll(Context context, boolean useBackgroundIndexing)
           
 long reIndexAll(Context context, boolean useBackgroundIndexing, boolean updateReplicatedIndex)
          Reindex all issues.
 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)
          Reindexes a collection of comments.
 long reIndexComments(Collection<Comment> comments, Context context)
          Reindexes a collection of comments.
 long reIndexComments(Collection<Comment> comments, Context context, boolean updateReplicatedIndexStore)
          Reindexes a collection of comments.
 long reIndexIssueObjects(Collection<? extends Issue> issueObjects)
          Reindex a set of issues.
 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 reIndexIssues(Collection<org.ofbiz.core.entity.GenericValue> issues)
          Reindex a set of issues (GenericValues).
protected  long reIndexIssues(Collection<org.ofbiz.core.entity.GenericValue> issues, boolean reIndexComments, boolean reIndexChangeHistory)
           
 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 release()
          Release indexing on this thread.
 void shutdown()
          Shuts down the indexing manager and closes its resources (if any).
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANALYZER_FOR_SEARCHING

public static final org.apache.lucene.analysis.Analyzer ANALYZER_FOR_SEARCHING

ANALYZER_FOR_INDEXING

public static final org.apache.lucene.analysis.Analyzer ANALYZER_FOR_INDEXING
Constructor Detail

DefaultIndexManager

public DefaultIndexManager(IndexingConfiguration indexProperties,
                           IssueIndexer issueIndexer,
                           IndexPathManager indexPath,
                           ReindexMessageManager reindexMessageManager,
                           com.atlassian.event.api.EventPublisher eventPublisher,
                           ListenerManager listenerManager,
                           ProjectManager projectManager,
                           IssueManager issueManager,
                           TaskManager taskManager,
                           OfBizDelegator ofBizDelegator,
                           ReplicatedIndexManager replicatedIndexManager)
Method Detail

getAnalyzerForSearching

public org.apache.lucene.analysis.Analyzer getAnalyzerForSearching()
Description copied from interface: IssueIndexManager
Returns an Analyzer for searching.

Specified by:
getAnalyzerForSearching in interface IssueIndexManager
Returns:
an analyzer for searching

getAnalyzerForIndexing

public org.apache.lucene.analysis.Analyzer getAnalyzerForIndexing()
Description copied from interface: IssueIndexManager
Returns an Analyzer for indexing.

Specified by:
getAnalyzerForIndexing in interface IssueIndexManager
Returns:
an analyzer for indexing.

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

isIndexingEnabled

public boolean isIndexingEnabled()
Specified by:
isIndexingEnabled in interface IndexLifecycleManager
Returns:
whether this index is enabled or true if all sub indexes are enabled

reIndexAll

public long reIndexAll()
                throws IndexException
Description copied from interface: IssueIndexManager
Reindex all issues.

Specified by:
reIndexAll in interface IssueIndexManager
Returns:
The number of milliseconds taken to reindex everything, or -1 if not indexing
Throws:
IndexException

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,
                       boolean useBackgroundIndexing)

reIndexAll

public long reIndexAll(Context context,
                       boolean useBackgroundIndexing,
                       boolean updateReplicatedIndex)
Description copied from interface: IssueIndexManager
Reindex all issues.

Specified by:
reIndexAll in interface IssueIndexManager
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 comments and change history will not be reindexed.
updateReplicatedIndex - whether to update the replicated index or not
Returns:
Reindex time in ms.

reIndexAll

public long reIndexAll(Context context,
                       boolean useBackgroundIndexing,
                       boolean reIndexComments,
                       boolean reIndexChangeHistory,
                       boolean updateReplicatedIndex)
Description copied from interface: IssueIndexManager
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.

Specified by:
reIndexAll in interface IssueIndexManager
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.

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.

reIndexAllIssuesInBackground

public long reIndexAllIssuesInBackground(Context context,
                                         boolean reIndexComments,
                                         boolean reIndexChangeHistory)
Description copied from interface: IndexLifecycleManager
Reindex everything, but don't stop the world

Specified by:
reIndexAllIssuesInBackground in interface IndexLifecycleManager
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.

reIndexIssues

public long reIndexIssues(Collection<org.ofbiz.core.entity.GenericValue> issues)
                   throws IndexException
Description copied from interface: IssueIndexManager
Reindex a set of issues (GenericValues). Use IssueIndexManager.reIndexIssueObjects(Collection) instead when possible.

Specified by:
reIndexIssues in interface IssueIndexManager
Parameters:
issues - The Issue GenericValues to reindex.
Returns:
Reindex time in ms.
Throws:
IndexException

reIndexIssues

protected long reIndexIssues(Collection<org.ofbiz.core.entity.GenericValue> issues,
                             boolean reIndexComments,
                             boolean reIndexChangeHistory)
                      throws IndexException
Throws:
IndexException

reIndexIssueObjects

public long reIndexIssueObjects(Collection<? extends Issue> issueObjects)
                         throws IndexException
Description copied from interface: IssueIndexManager
Reindex a set of issues.

Specified by:
reIndexIssueObjects in interface IssueIndexManager
Parameters:
issueObjects - Set of Issues to reindex.
Returns:
Reindex time in ms.
Throws:
IndexException

reIndexIssueObjects

public long reIndexIssueObjects(Collection<? extends Issue> issueObjects,
                                boolean reIndexComments,
                                boolean reIndexChangeHistory)
                         throws IndexException
Description copied from interface: IssueIndexManager
Reindex a set of issues.

Specified by:
reIndexIssueObjects in interface IssueIndexManager
Parameters:
issueObjects - Set of Issues to reindex.
Returns:
Reindex time in ms.
Throws:
IndexException

reIndexIssueObjects

public long reIndexIssueObjects(Collection<? extends Issue> issueObjects,
                                boolean reIndexComments,
                                boolean reIndexChangeHistory,
                                boolean updateReplicatedIndexStore)
                         throws IndexException
Description copied from interface: IssueIndexManager
Reindex a set of issues.

Specified by:
reIndexIssueObjects in interface IssueIndexManager
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.
Throws:
IndexException

reIndex

public void reIndex(Issue issue)
             throws IndexException
Description copied from interface: IssueIndexManager
Reindex an issue (eg. after field updates).

Specified by:
reIndex in interface IssueIndexManager
Throws:
IndexException

reIndex

public void reIndex(Issue issue,
                    boolean reIndexComments,
                    boolean reIndexChangeHistory)
             throws IndexException
Description copied from interface: IssueIndexManager
Reindex an issue (eg. after field updates).

Specified by:
reIndex in interface IssueIndexManager
Throws:
IndexException

reIndex

public void reIndex(org.ofbiz.core.entity.GenericValue issueGV)
             throws IndexException
Description copied from interface: IssueIndexManager
Reindex an issue (eg. after field updates).

Specified by:
reIndex in interface IssueIndexManager
Throws:
IndexException

hold

public void hold()
Description copied from interface: IssueIndexManager
Temporarily suspend indexing on this thread. All index requests will be queued and processed when release is called.

Specified by:
hold in interface IssueIndexManager

isHeld

public boolean isHeld()
Description copied from interface: IssueIndexManager
Return true if the index is held.

Specified by:
isHeld in interface IssueIndexManager

release

public long release()
             throws IndexException
Description copied from interface: IssueIndexManager
Release indexing on this thread. All queued index requests will be processed.

Specified by:
release in interface IssueIndexManager
Returns:
Reindex time in ms.
Throws:
IndexException - if an error occurs

reIndexIssues

public long reIndexIssues(IssuesIterable issuesIterable,
                          Context context)
                   throws IndexException
Description copied from interface: IssueIndexManager
Reindex a list of issues, passing an optional event that will be set progress

Specified by:
reIndexIssues in interface IssueIndexManager
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,
                          boolean reIndexComments,
                          boolean reIndexChangeHistory)
                   throws IndexException
Description copied from interface: IssueIndexManager
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 IssueIndexManager
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.
Throws:
IndexException

reIndexComments

public long reIndexComments(Collection<Comment> comments)
                     throws IndexException
Description copied from interface: IssueIndexManager
Reindexes a collection of comments.

Specified by:
reIndexComments in interface IssueIndexManager
Parameters:
comments - a collection of Comment
Throws:
IndexException

reIndexComments

public long reIndexComments(Collection<Comment> comments,
                            Context context)
                     throws IndexException
Description copied from interface: IssueIndexManager
Reindexes a collection of comments.

Specified by:
reIndexComments in interface IssueIndexManager
Parameters:
comments - a collection of Comment
context - used to report progress back to the user or to the logs. Must not be null.
Throws:
IndexException

reIndexComments

public long reIndexComments(Collection<Comment> comments,
                            Context context,
                            boolean updateReplicatedIndexStore)
                     throws IndexException
Description copied from interface: IssueIndexManager
Reindexes a collection of comments.

Specified by:
reIndexComments in interface IssueIndexManager
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
Throws:
IndexException

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. A background re-index should not be attempted when this returns false.

size

public int size()
Specified by:
size in interface Sized
Specified by:
size in interface IndexLifecycleManager
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.

deIndex

public void deIndex(Issue issue)
             throws IndexException
Description copied from interface: IssueIndexManager
Remove an issue from the search index.

Specified by:
deIndex in interface IssueIndexManager
Throws:
IndexException

deIndexIssueObjects

public void deIndexIssueObjects(Set<Issue> issuesToDelete,
                                boolean updateReplicatedIndexStore)
                         throws IndexException
Description copied from interface: IssueIndexManager
Remove a set of issues from the search index.

Specified by:
deIndexIssueObjects in interface IssueIndexManager
Throws:
IndexException

deIndex

public void deIndex(org.ofbiz.core.entity.GenericValue entity)
             throws IndexException
Description copied from interface: IssueIndexManager
Remove an issue from the search index.

Specified by:
deIndex in interface IssueIndexManager
Throws:
IndexException

getPluginsRootPath

public String getPluginsRootPath()
Description copied from interface: IssueIndexManager
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

Specified by:
getPluginsRootPath in interface IssueIndexManager

getExistingPluginsPaths

public List<String> getExistingPluginsPaths()
Description copied from interface: IssueIndexManager
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 IssueIndexManager.getPluginsRootPath().

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

Specified by:
getExistingPluginsPaths in interface IssueIndexManager

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.

getIssueSearcher

public org.apache.lucene.search.IndexSearcher getIssueSearcher()
Description copied from interface: IssueIndexManager
Get an IndexSearcher that can be used to search the issue index.

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

Specified by:
getIssueSearcher in interface IssueIndexManager

getCommentSearcher

public org.apache.lucene.search.IndexSearcher getCommentSearcher()
Description copied from interface: IssueIndexManager
Get an IndexSearcher that can be used to search the comment index.

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

Specified by:
getCommentSearcher in interface IssueIndexManager

getChangeHistorySearcher

public org.apache.lucene.search.IndexSearcher getChangeHistorySearcher()
Description copied from interface: IssueIndexManager
Get an IndexSearcher that can be used to search the change history index.

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

Specified by:
getChangeHistorySearcher in interface IssueIndexManager

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

flushThreadLocalSearchers

public static void flushThreadLocalSearchers()


Copyright © 2002-2014 Atlassian. All Rights Reserved.