Package org.apache.lucene.index
Class ConcurrentMergeScheduler
- java.lang.Object
 - 
- org.apache.lucene.index.MergeScheduler
 - 
- org.apache.lucene.index.ConcurrentMergeScheduler
 
 
 
- 
- All Implemented Interfaces:
 java.io.Closeable,java.lang.AutoCloseable,java.lang.Cloneable
public class ConcurrentMergeScheduler extends MergeScheduler
AMergeSchedulerthat runs each merge using a separate thread.Specify the max number of threads that may run at once, and the maximum number of simultaneous merges with
setMaxMergesAndThreads(int, int).If the number of merges exceeds the max number of threads then the largest merges are paused until one of the smaller merges completes.
If more than
getMaxMergeCount()merges are requested then this class will forcefully throttle the incoming threads by pausing until one more more merges complete. 
- 
- 
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_MERGE_COUNTDefaultmaxMergeCount.static intDEFAULT_MAX_THREAD_COUNTDefaultmaxThreadCount. 
- 
Constructor Summary
Constructors Constructor Description ConcurrentMergeScheduler()Sole constructor, with all settings set to default values. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MergeSchedulerclone()voidclose()Close this MergeScheduler.intgetMaxMergeCount()intgetMaxThreadCount()ReturnsmaxThreadCount.intgetMergeThreadPriority()Return the priority that merge threads run at.voidmerge(IndexWriter writer)Run the merges provided byIndexWriter.getNextMerge().voidsetMaxMergesAndThreads(int maxMergeCount, int maxThreadCount)Sets the maximum number of merge threads and simultaneous merges allowed.voidsetMergeThreadPriority(int pri)Set the base priority that merge threads run at.voidsync()Wait for any running merge threads to finish.java.lang.StringtoString() 
 - 
 
- 
- 
Field Detail
- 
DEFAULT_MAX_THREAD_COUNT
public static final int DEFAULT_MAX_THREAD_COUNT
DefaultmaxThreadCount. We default to 1: tests on spinning-magnet drives showed slower indexing performance if more than one merge thread runs at once (though on an SSD it was faster)- See Also:
 - Constant Field Values
 
 
- 
DEFAULT_MAX_MERGE_COUNT
public static final int DEFAULT_MAX_MERGE_COUNT
DefaultmaxMergeCount.- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
setMaxMergesAndThreads
public void setMaxMergesAndThreads(int maxMergeCount, int maxThreadCount)Sets the maximum number of merge threads and simultaneous merges allowed.- Parameters:
 maxMergeCount- the max # simultaneous merges that are allowed. If a merge is necessary yet we already have this many threads running, the incoming thread (that is calling add/updateDocument) will block until a merge thread has completed. Note that we will only run the smallestmaxThreadCountmerges at a time.maxThreadCount- the max # simultaneous merge threads that should be running at once. This must be <=maxMergeCount
 
- 
getMaxThreadCount
public int getMaxThreadCount()
ReturnsmaxThreadCount.- See Also:
 setMaxMergesAndThreads(int, int)
 
- 
getMaxMergeCount
public int getMaxMergeCount()
 
- 
getMergeThreadPriority
public int getMergeThreadPriority()
Return the priority that merge threads run at. By default the priority is 1 plus the priority of (ie, slightly higher priority than) the first thread that calls merge. 
- 
setMergeThreadPriority
public void setMergeThreadPriority(int pri)
Set the base priority that merge threads run at. Note that CMS may increase priority of some merge threads beyond this base priority. It's best not to set this any higher than Thread.MAX_PRIORITY-maxThreadCount, so that CMS has room to set relative priority among threads. 
- 
close
public void close()
Description copied from class:MergeSchedulerClose this MergeScheduler.- Specified by:
 closein interfacejava.lang.AutoCloseable- Specified by:
 closein interfacejava.io.Closeable- Specified by:
 closein classMergeScheduler
 
- 
sync
public void sync()
Wait for any running merge threads to finish. This call is not interruptible as used byclose(). 
- 
merge
public void merge(IndexWriter writer) throws java.io.IOException
Description copied from class:MergeSchedulerRun the merges provided byIndexWriter.getNextMerge().- Specified by:
 mergein classMergeScheduler- Throws:
 java.io.IOException
 
- 
toString
public java.lang.String toString()
- Overrides:
 toStringin classjava.lang.Object
 
- 
clone
public MergeScheduler clone()
- Overrides:
 clonein classMergeScheduler
 
 - 
 
 -