com.atlassian.bonnie.index
Class BaseMultiThreadedIndexer

java.lang.Object
  extended by com.atlassian.bonnie.index.BaseMultiThreadedIndexer
All Implemented Interfaces:
BatchOpIndexer
Direct Known Subclasses:
OnlineMultiThreadedIndexer

public abstract class BaseMultiThreadedIndexer
extends java.lang.Object
implements BatchOpIndexer

Multiple-thread implementation of a BatchOpIndexer


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.bonnie.index.BatchOpIndexer
BatchOpIndexer.DocumentWritingScheme
 
Field Summary
protected static org.apache.log4j.Category log
           
protected  LuceneConnection luceneConnection
           
 
Constructor Summary
BaseMultiThreadedIndexer()
           
 
Method Summary
protected abstract  void allThreadsComplete(BatchOpIndexer.DocumentWritingScheme scheme, boolean truncate, com.atlassian.core.util.ProgressWrapper progress)
          Perform clean-up operations such as closing writers, optimizing, merging with original index, etc.
protected  int calculateNumberOfThreads(int numObjects)
          Determine how many threads to use.
protected  java.lang.Runnable getQueueProcessingRunnable(ObjectQueue queue, BatchOpIndexer.DocumentWritingScheme documentWritingScheme)
           
protected  boolean isReindexing()
          Is reindexing currently underway? Distinct from LuceneConnection.isReIndexing() in that this method is for internal use, whilst the LuceneConnection equivalent is for all potential users of the index, whether in- or out-of-process clients.
 void reindex(ObjectQueue queue, BatchOpIndexer.DocumentWritingScheme documentWritingScheme, com.atlassian.core.util.ProgressMeter meter, boolean truncate)
          Indexes objects in batch.
 void setReindexing(boolean reindexing)
           
 void truncateIndex()
          Truncate the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.bonnie.index.BatchOpIndexer
getAnalyzer
 

Field Detail

log

protected static org.apache.log4j.Category log

luceneConnection

protected LuceneConnection luceneConnection
Constructor Detail

BaseMultiThreadedIndexer

public BaseMultiThreadedIndexer()
Method Detail

reindex

public final void reindex(ObjectQueue queue,
                          BatchOpIndexer.DocumentWritingScheme documentWritingScheme,
                          com.atlassian.core.util.ProgressMeter meter,
                          boolean truncate)
Description copied from interface: BatchOpIndexer
Indexes objects in batch.

Specified by:
reindex in interface BatchOpIndexer
Parameters:
queue - queue of objects to index
documentWritingScheme - document writing scheme to use
meter - progress meter indicating index progress
truncate - should the original index be truncated?

getQueueProcessingRunnable

protected java.lang.Runnable getQueueProcessingRunnable(ObjectQueue queue,
                                                        BatchOpIndexer.DocumentWritingScheme documentWritingScheme)

truncateIndex

public void truncateIndex()
                   throws java.io.IOException
Description copied from interface: BatchOpIndexer
Truncate the index. Depending on implementations, this can mean deleting the documents one by one, or other more efficient ways of removing documents from the index. Either way, this method results in an empty (but valid) Lucene index.

Specified by:
truncateIndex in interface BatchOpIndexer
Throws:
java.io.IOException

allThreadsComplete

protected abstract void allThreadsComplete(BatchOpIndexer.DocumentWritingScheme scheme,
                                           boolean truncate,
                                           com.atlassian.core.util.ProgressWrapper progress)
Perform clean-up operations such as closing writers, optimizing, merging with original index, etc.

Parameters:
scheme - scheme
truncate - should the original index be truncated

calculateNumberOfThreads

protected int calculateNumberOfThreads(int numObjects)
Determine how many threads to use.

Parameters:
numObjects - the number of objects to index
Returns:
number of threads

isReindexing

protected boolean isReindexing()
Is reindexing currently underway? Distinct from LuceneConnection.isReIndexing() in that this method is for internal use, whilst the LuceneConnection equivalent is for all potential users of the index, whether in- or out-of-process clients.

Returns:
true if the reindex method is currently running.

setReindexing

public void setReindexing(boolean reindexing)


Copyright © 2006-2008 Atlassian Software Systems Pty Ltd. All Rights Reserved.