You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by mi...@apache.org on 2009/06/23 23:08:17 UTC
svn commit: r787834 - in /lucene/java/trunk: CHANGES.txt
src/java/org/apache/lucene/index/IndexWriter.java
Author: mikemccand
Date: Tue Jun 23 21:08:16 2009
New Revision: 787834
URL: http://svn.apache.org/viewvc?rev=787834&view=rev
Log:
LUCENE-1703: add IndexWriter.waitForMerges
Modified:
lucene/java/trunk/CHANGES.txt
lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=787834&r1=787833&r2=787834&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Jun 23 21:08:16 2009
@@ -262,6 +262,9 @@
of characters before tokenizers run. (Koji Sekiguchi via Mike
McCandless)
+26. LUCENE-1703: Add IndexWriter.waitForMerges. (Tim Smith via Mike
+ McCandless)
+
Bug fixes
1. LUCENE-1415: MultiPhraseQuery has incorrect hashCode() and equals()
Modified: lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java?rev=787834&r1=787833&r2=787834&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/index/IndexWriter.java Tue Jun 23 21:08:16 2009
@@ -3286,19 +3286,34 @@
message("all running merges have aborted");
} else {
- // Ensure any running addIndexes finishes. It's fine
- // if a new one attempts to start because from our
+ // waitForMerges() will ensure any running addIndexes finishes.
+ // It's fine if a new one attempts to start because from our
// caller above the call will see that we are in the
// process of closing, and will throw an
// AlreadyClosedException.
- acquireRead();
- releaseRead();
- while(pendingMerges.size() > 0 || runningMerges.size() > 0)
- doWait();
- assert 0 == mergingSegments.size();
+ waitForMerges();
}
}
-
+
+ /**
+ * Wait for any currently outstanding merges to finish.
+ *
+ * <p>It is guaranteed that any merges started prior to calling this method
+ * will have completed once this method completes.</p>
+ */
+ public synchronized void waitForMerges() {
+ // Ensure any running addIndexes finishes.
+ acquireRead();
+ releaseRead();
+
+ while(pendingMerges.size() > 0 || runningMerges.size() > 0) {
+ doWait();
+ }
+
+ // sanity check
+ assert 0 == mergingSegments.size();
+ }
+
/*
* Called whenever the SegmentInfos has been updated and
* the index files referenced exist (correctly) in the