LUCENE-5438: make some APIs public so servers can actually use this feature

This commit is contained in:
Mike McCandless 2016-07-25 06:00:11 -04:00
parent 4c61d5aacc
commit 2d07ffd97f
2 changed files with 20 additions and 4 deletions

View File

@ -25,6 +25,7 @@ import java.io.PrintStream;
import java.nio.file.NoSuchFileException;
import java.util.Locale;
import java.util.Map;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.DirectoryReader;
@ -39,10 +40,10 @@ import org.apache.lucene.store.IndexInput;
*
* @lucene.experimental */
abstract class Node implements Closeable {
public abstract class Node implements Closeable {
static boolean VERBOSE_FILES = true;
static boolean VERBOSE_CONNECTIONS = false;
public static boolean VERBOSE_FILES = true;
public static boolean VERBOSE_CONNECTIONS = false;
// Keys we store into IndexWriter's commit user data:
@ -87,6 +88,16 @@ abstract class Node implements Closeable {
this.printStream = printStream;
}
/** Returns the {@link ReferenceManager} to use for acquiring and releasing searchers */
public ReferenceManager<IndexSearcher> getSearcherManager() {
return mgr;
}
/** Returns the {@link Directory} this node is writing to */
public Directory getDirectory() {
return dir;
}
@Override
public String toString() {
return getClass().getSimpleName() + "(id=" + id + ")";
@ -119,7 +130,7 @@ abstract class Node implements Closeable {
}
}
protected void message(String message) {
public void message(String message) {
if (printStream != null) {
long now = System.nanoTime();
printStream.println(String.format(Locale.ROOT,

View File

@ -128,6 +128,11 @@ public abstract class PrimaryNode extends Node {
}
}
/** Returns the current primary generation, which is incremented each time a new primary is started for this index */
public long getPrimaryGen() {
return primaryGen;
}
// TODO: in the future, we should separate "flush" (returns an incRef'd SegmentInfos) from "refresh" (open new NRT reader from
// IndexWriter) so that the latter can be done concurrently while copying files out to replicas, minimizing the refresh time from the
// replicas. But fixing this is tricky because e.g. IndexWriter may complete a big merge just after returning the incRef'd SegmentInfos