add getter for the current searching generation

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1719986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-12-14 18:38:25 +00:00
parent f81f939b54
commit 8cc1f0e50f
2 changed files with 11 additions and 2 deletions

View File

@ -181,7 +181,7 @@ public class ControlledRealTimeReopenThread<T> extends Thread implements Closeab
if (maxMS < 0) {
wait();
} else {
long msLeft = (startMS + maxMS) - (System.nanoTime())/1000000;
long msLeft = (startMS + maxMS) - System.nanoTime()/1000000;
if (msLeft <= 0) {
return false;
} else {
@ -248,4 +248,9 @@ public class ControlledRealTimeReopenThread<T> extends Thread implements Closeab
}
}
}
/** Returns which {@code generation} the current searcher is guaranteed to include. */
public long getSearchingGen() {
return searchingGen;
}
}

View File

@ -24,7 +24,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -103,6 +102,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
System.out.println(Thread.currentThread().getName() + ": nrt: verify " + id);
}
nrtDeletesThread.waitForGeneration(gen);
assertTrue(gen <= nrtDeletesThread.getSearchingGen());
final IndexSearcher s = nrtDeletes.acquire();
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": nrt: got searcher=" + s);
@ -126,6 +126,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
System.out.println(Thread.currentThread().getName() + ": nrt: verify " + id);
}
nrtNoDeletesThread.waitForGeneration(gen);
assertTrue(gen <= nrtNoDeletesThread.getSearchingGen());
final IndexSearcher s = nrtNoDeletes.acquire();
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": nrt: got searcher=" + s);
@ -149,6 +150,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
System.out.println(Thread.currentThread().getName() + ": nrt: verify " + id);
}
nrtNoDeletesThread.waitForGeneration(gen);
assertTrue(gen <= nrtNoDeletesThread.getSearchingGen());
final IndexSearcher s = nrtNoDeletes.acquire();
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": nrt: got searcher=" + s);
@ -171,6 +173,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
System.out.println(Thread.currentThread().getName() + ": nrt: verify " + id);
}
nrtDeletesThread.waitForGeneration(gen);
assertTrue(gen <= nrtDeletesThread.getSearchingGen());
final IndexSearcher s = nrtDeletes.acquire();
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": nrt: got searcher=" + s);
@ -193,6 +196,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
System.out.println(Thread.currentThread().getName() + ": nrt: verify del " + id);
}
nrtDeletesThread.waitForGeneration(gen);
assertTrue(gen <= nrtDeletesThread.getSearchingGen());
final IndexSearcher s = nrtDeletes.acquire();
if (VERBOSE) {
System.out.println(Thread.currentThread().getName() + ": nrt: got searcher=" + s);