com.atlassian.jira.issue.index
Class DefaultIndexManager

java.lang.Object
  extended by com.atlassian.jira.issue.index.DefaultIndexManager
All Implemented Interfaces:
IssueIndexManager
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
           
static String COMMENTS_SUBDIR
           
static String ISSUES_SUBDIR
           
static String PLUGINS_SUBDIR
           
 
Constructor Summary
DefaultIndexManager()
           
DefaultIndexManager(ApplicationProperties applicationProperties, IssueIndexer issueIndexer)
           
 
Method Summary
 long activate(String indexPath, com.atlassian.johnson.event.Event appEvent)
          Activates search indexes.
 void deactivate()
          Deactivates indexing (as happens from the admin page) and removes index directories.
 void deactivate(String filePath)
          Deactivate a specific search index and remove its directory.
 void deIndex(org.ofbiz.core.entity.GenericValue entity)
          Remove an issue from the search index.
 Collection getAllIndexPaths()
          Returns a Collection of Strings, each respesenting a path to the issue index directory, comment index directory and all existing plugin index directories.
 org.apache.lucene.search.IndexSearcher getCommentSearcher()
          Get an IndexSearcher that can be used to search the comment index.
 Collection getExistingPluginsPaths()
          Returns a collection of Strings, each one representing the absolute path to the actual existing directory where a plugin keeps its indexes.
protected  String getFilePath()
          Return the path beneath which the different index directories are stored, protected so the MemoryIndexManager can override for testing purposes.
(package private)  boolean getIndexLock()
          this is package private as tests override it
 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.
(package private)  int getReindexesSinceOptimize()
          Get the count of reindexes since the last call to optimize.
 boolean isIndexingEnabled()
          Is the indexing system enabled.
 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.
 long reIndexAll()
          Reindex all issues.
 long reIndexAll(com.atlassian.johnson.event.Event event)
          Reindex all issues.
 long reIndexIssueObjects(Collection issueObjects)
          Reindex a set of issues.
 long reIndexIssues(Collection issues)
          Reindex a set of issues (GenericValues).
 long reIndexIssues(IssuesIterable issuesIterable, com.atlassian.johnson.event.Event event)
          Reindex a list of issues, passing an optional event that will be set progress
 void shutdown()
          Shuts down the indexing manager and closes its resources (if any).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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

COMMENTS_SUBDIR

public static final String COMMENTS_SUBDIR
See Also:
Constant Field Values

ISSUES_SUBDIR

public static final String ISSUES_SUBDIR
See Also:
Constant Field Values

PLUGINS_SUBDIR

public static final String PLUGINS_SUBDIR
See Also:
Constant Field Values
Constructor Detail

DefaultIndexManager

public DefaultIndexManager()

DefaultIndexManager

public DefaultIndexManager(ApplicationProperties applicationProperties,
                           IssueIndexer issueIndexer)
Method Detail

deactivate

public void deactivate(String filePath)
                throws Exception
Description copied from interface: IssueIndexManager
Deactivate a specific search index and remove its directory.

Specified by:
deactivate in interface IssueIndexManager
Throws:
Exception

deactivate

public void deactivate()
                throws Exception
Description copied from interface: IssueIndexManager
Deactivates indexing (as happens from the admin page) and removes index directories.

Specified by:
deactivate in interface IssueIndexManager
Throws:
Exception

activate

public long activate(String indexPath,
                     com.atlassian.johnson.event.Event appEvent)
              throws Exception
Description copied from interface: IssueIndexManager
Activates search indexes.

Specified by:
activate in interface IssueIndexManager
Parameters:
indexPath - Root path to the search index.
appEvent - Optional reindex Event that the caller has set (see source in IndexAdminImpl.doActivate()) or null.
Returns:
Reindex time in ms
Throws:
Exception

isIndexingEnabled

public boolean isIndexingEnabled()
Description copied from interface: IssueIndexManager
Is the indexing system enabled.

Specified by:
isIndexingEnabled in interface IssueIndexManager

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(com.atlassian.johnson.event.Event event)
                throws IndexException
Description copied from interface: IssueIndexManager
Reindex all issues.

Specified by:
reIndexAll in interface IssueIndexManager
Parameters:
event - Reindex Event that the caller has set (see source in IndexAdminImpl.doActivate()).
Returns:
Reindex time in ms.
Throws:
IndexException

reIndexIssues

public long reIndexIssues(Collection 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

reIndexIssueObjects

public long reIndexIssueObjects(Collection 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

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(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

reIndexIssues

public long reIndexIssues(IssuesIterable issuesIterable,
                          com.atlassian.johnson.event.Event event)
                   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
event - Can be null, else progress will be sent to the event
Returns:
Reindex time in ms.
Throws:
IndexException

optimize

public long optimize()
              throws IndexException
Description copied from interface: IssueIndexManager
Optimize the underlying indexes. Make the subsequent searching more efficient.

Specified by:
optimize in interface IssueIndexManager
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.
Throws:
IndexException - if the indexes are seriously in trouble

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

getIndexLock

boolean getIndexLock()
this is package private as tests override it


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 Collection 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 getAllIndexPaths()
Description copied from interface: IssueIndexManager
Returns a Collection of Strings, each respesenting a path to the issue index directory, comment index directory and all existing plugin index directories.

Specified by:
getAllIndexPaths in interface IssueIndexManager

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

shutdown

public void shutdown()
Description copied from interface: IssueIndexManager
Shuts down the indexing manager and closes its resources (if any).

Specified by:
shutdown in interface IssueIndexManager

getReindexesSinceOptimize

int getReindexesSinceOptimize()
Get the count of reindexes since the last call to optimize.

Note: package private as be used in tests.


getFilePath

protected String getFilePath()
Return the path beneath which the different index directories are stored, protected so the MemoryIndexManager can override for testing purposes.



Copyright © 2002-2007 Atlassian. All Rights Reserved.