|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.atlassian.bonnie.ConcurrentLuceneConnection
ILuceneConnection implementation that allows concurrent searching/reading and writing/deleting. Concurrent writes and deletes block each other.
This class optimizes use of Lucene reader instances by holding a common IndexReader that is shared by idempotent operations on an unmodified index. Any mutative operations cause the current IndexReader to be cleared, and subsequent reads will see the results of the previous index change. TODO We might need to keep track of currently open readers and blockrecreateIndexDirectory() until they are all closed. We would
also need to prevent any new Readers being created during this time. The reason for this is that Windoze can whinge
about open file crap and refuse to delete files rather than listen to its l33t haxor ruler.
| Nested Class Summary |
| Nested classes inherited from class com.atlassian.bonnie.ILuceneConnection |
ILuceneConnection.BatchUpdateAction, ILuceneConnection.Configuration, ILuceneConnection.ReaderAction, ILuceneConnection.SearcherAction, ILuceneConnection.WriterAction |
| Field Summary |
| Fields inherited from interface com.atlassian.bonnie.ILuceneConnection |
DEFAULT_CONFIGURATION |
| Constructor Summary | |
ConcurrentLuceneConnection(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer,
ILuceneConnection.Configuration configuration)
|
|
ConcurrentLuceneConnection(java.io.File path,
org.apache.lucene.analysis.Analyzer analyzer,
ILuceneConnection.Configuration configuration)
|
|
| Method Summary | |
void |
close()
Closes the reader and the writer. |
void |
flipCurrentSearcher()
Closes the searcher that is currently in use. |
int |
getNumDocs()
Returns the number of documents in the index. |
boolean |
isIndexCreated()
Returns true if the index has been created. |
org.apache.lucene.search.IndexSearcher |
leakSearcher()
Get the current Searcher from the ILuceneConnection. |
void |
optimize()
Blocks and waits until all write operations to the index complete. |
void |
recreateIndexDirectory()
Blocks and waits until all write operations to the index complete. |
void |
withBatchUpdate(ILuceneConnection.BatchUpdateAction action)
Blocks and waits until all write operations to the index complete. |
void |
withDeleteAndWrites(ILuceneConnection.ReaderAction readerAction,
ILuceneConnection.WriterAction writerAction)
Perform an Atomic delete and add. |
java.lang.Object |
withReader(ILuceneConnection.ReaderAction action)
Idempotent operation. |
void |
withReaderAndDeletes(ILuceneConnection.ReaderAction action)
Blocks and waits until all write operations to the index complete. |
void |
withSearch(ILuceneConnection.SearcherAction action)
This implementation does not respect the boolean return of the of the SearcherAction#perform(org.apache.lucene.search.IndexSearcher) method |
void |
withWriter(ILuceneConnection.WriterAction action)
Blocks and waits until all write operations to the index complete. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ConcurrentLuceneConnection(org.apache.lucene.store.Directory directory,
org.apache.lucene.analysis.Analyzer analyzer,
ILuceneConnection.Configuration configuration)
public ConcurrentLuceneConnection(java.io.File path,
org.apache.lucene.analysis.Analyzer analyzer,
ILuceneConnection.Configuration configuration)
| Method Detail |
public int getNumDocs()
ILuceneConnectiondocuments in the index.
getNumDocs in interface ILuceneConnectionpublic boolean isIndexCreated()
ILuceneConnection
isIndexCreated in interface ILuceneConnectionpublic org.apache.lucene.search.IndexSearcher leakSearcher()
ILuceneConnection
leakSearcher in interface ILuceneConnection
public void optimize()
throws LuceneException
optimize in interface ILuceneConnectionLuceneExceptionpublic void recreateIndexDirectory()
recreateIndexDirectory in interface ILuceneConnectionpublic void close()
ILuceneConnection
close in interface ILuceneConnection
public void withSearch(ILuceneConnection.SearcherAction action)
throws LuceneException
SearcherAction#perform(org.apache.lucene.search.IndexSearcher) method
withSearch in interface ILuceneConnectionLuceneException
public java.lang.Object withReader(ILuceneConnection.ReaderAction action)
throws LuceneException
ILuceneConnection#withReaderAndDeletes(ReaderAction) to perform
index deletes.
withReader in interface ILuceneConnectionLuceneException
public void withReaderAndDeletes(ILuceneConnection.ReaderAction action)
throws LuceneException
withReaderAndDeletes in interface ILuceneConnectionLuceneException
public void withWriter(ILuceneConnection.WriterAction action)
throws LuceneException
withWriter in interface ILuceneConnectionLuceneException
public void withDeleteAndWrites(ILuceneConnection.ReaderAction readerAction,
ILuceneConnection.WriterAction writerAction)
throws LuceneException
ILuceneConnectionILuceneConnection.withBatchUpdate(com.atlassian.bonnie.ILuceneConnection.BatchUpdateAction) as
it will use the batch mode configuration, speeding up the writes.
withDeleteAndWrites in interface ILuceneConnectionLuceneExceptionpublic void withBatchUpdate(ILuceneConnection.BatchUpdateAction action)
withBatchUpdate in interface ILuceneConnectionpublic void flipCurrentSearcher()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||