public class

ConcurrentMergeScheduler

extends MergeScheduler
java.lang.Object
   ↳ org.apache.lucene.index.MergeScheduler
     ↳ org.apache.lucene.index.ConcurrentMergeScheduler

Class Overview

A MergeScheduler that runs each merge using a separate thread, up until a maximum number of threads (setMaxThreadCount(int)) at which when a merge is needed, the thread(s) that are updating the index will pause until one or more merges completes. This is a simple way to use concurrency in the indexing process without having to create and manage application level threads.

Summary

Nested Classes
class ConcurrentMergeScheduler.MergeThread  
Fields
protected Directory dir
protected int mergeThreadCount
protected List<ConcurrentMergeScheduler.MergeThread> mergeThreads
protected IndexWriter writer
Public Constructors
ConcurrentMergeScheduler()
Public Methods
static boolean anyUnhandledExceptions()
Used for testing
static void clearUnhandledExceptions()
void close()
Close this MergeScheduler.
int getMaxThreadCount()
Get the max # simultaneous threads that may be running.
synchronized int getMergeThreadPriority()
Return the priority that merge threads run at.
void merge(IndexWriter writer)
Run the merges provided by IndexWriter#getNextMerge().
void setMaxThreadCount(int count)
Sets the max # simultaneous threads that may be running.
synchronized void setMergeThreadPriority(int pri)
Set the priority that merge threads run at.
static void setTestMode()
synchronized void sync()
Protected Methods
void doMerge(MergePolicy.OneMerge merge)
Does the actual merge, by calling IndexWriter#merge
synchronized ConcurrentMergeScheduler.MergeThread getMergeThread(IndexWriter writer, MergePolicy.OneMerge merge)
Create and return a new MergeThread
void handleMergeException(Throwable exc)
Called when an exception is hit in a background merge thread
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected Directory dir

protected int mergeThreadCount

protected List<ConcurrentMergeScheduler.MergeThread> mergeThreads

protected IndexWriter writer

Public Constructors

public ConcurrentMergeScheduler ()

Public Methods

public static boolean anyUnhandledExceptions ()

Used for testing

public static void clearUnhandledExceptions ()

public void close ()

Close this MergeScheduler.

public int getMaxThreadCount ()

Get the max # simultaneous threads that may be running. @see #setMaxThreadCount.

public synchronized 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.

public void merge (IndexWriter writer)

Run the merges provided by IndexWriter#getNextMerge().

public void setMaxThreadCount (int count)

Sets the max # simultaneous threads that may be running. 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.

public synchronized void setMergeThreadPriority (int pri)

Set the priority that merge threads run at.

public static void setTestMode ()

public synchronized void sync ()

Protected Methods

protected void doMerge (MergePolicy.OneMerge merge)

Does the actual merge, by calling IndexWriter#merge

Throws
IOException

protected synchronized ConcurrentMergeScheduler.MergeThread getMergeThread (IndexWriter writer, MergePolicy.OneMerge merge)

Create and return a new MergeThread

Throws
IOException

protected void handleMergeException (Throwable exc)

Called when an exception is hit in a background merge thread