mirror of https://github.com/apache/lucene.git
LUCENE-1703: add IndexWriter.waitForMerges
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@787834 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2d93f7e288
commit
629c7ed4c7
|
@ -262,6 +262,9 @@ API Changes
|
|||
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()
|
||||
|
|
|
@ -3286,17 +3286,32 @@ public class IndexWriter {
|
|||
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.
|
||||
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)
|
||||
|
||||
while(pendingMerges.size() > 0 || runningMerges.size() > 0) {
|
||||
doWait();
|
||||
assert 0 == mergingSegments.size();
|
||||
}
|
||||
|
||||
// sanity check
|
||||
assert 0 == mergingSegments.size();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue