Package org.apache.lucene.replicator.nrt
Class Node
- java.lang.Object
-
- org.apache.lucene.replicator.nrt.Node
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
PrimaryNode,ReplicaNode
public abstract class Node extends Object implements Closeable
Common base class forPrimaryNodeandReplicaNode.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description protected Directorydirstatic longglobalStartNSStartup time of original test, carefully propogated to all nodes to produce consistent "seconds since start time" in messagesprotected intidCompact ordinal for this nodeprotected Map<String,FileMetaData>lastFileMetaDataFile metadata for last sync that succeeded; we use this as a cachestatic longlocalStartNSWhen this node was startedprotected ReferenceManager<IndexSearcher>mgrstatic StringPRIMARY_GEN_KEYKey to store the primary gen in the commit data, which increments every time we promote a new primary, so replicas can detect when the primary they were talking to is changedprotected PrintStreamprintStreamFor debug loggingprotected SearcherFactorysearcherFactorystatic booleanVERBOSE_CONNECTIONSstatic booleanVERBOSE_FILESstatic StringVERSION_KEYKey to store the version in the commit data, which increments every time we open a new NRT reader
-
Constructor Summary
Constructors Constructor Description Node(int id, Directory dir, SearcherFactory searcherFactory, PrintStream printStream)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static StringbytesToString(long bytes)abstract voidcommit()longgetCurrentSearchingVersion()DirectorygetDirectory()Returns theDirectorythis node is writing toReferenceManager<IndexSearcher>getSearcherManager()Returns theReferenceManagerto use for acquiring and releasing searchersabstract booleanisClosed()voidmessage(String message)Stringname()static voidnodeMessage(PrintStream printStream, int id, String message)static voidnodeMessage(PrintStream printStream, String message)FileMetaDatareadLocalFileMetaData(String fileName)Opens the specified file, reads its identifying information, including file length, full index header (includes the unique segment ID) and the full footer (includes checksum), and returns the resultingFileMetaData.StringtoString()
-
-
-
Field Detail
-
VERBOSE_FILES
public static boolean VERBOSE_FILES
-
VERBOSE_CONNECTIONS
public static boolean VERBOSE_CONNECTIONS
-
PRIMARY_GEN_KEY
public static String PRIMARY_GEN_KEY
Key to store the primary gen in the commit data, which increments every time we promote a new primary, so replicas can detect when the primary they were talking to is changed
-
VERSION_KEY
public static String VERSION_KEY
Key to store the version in the commit data, which increments every time we open a new NRT reader
-
id
protected final int id
Compact ordinal for this node
-
dir
protected final Directory dir
-
searcherFactory
protected final SearcherFactory searcherFactory
-
mgr
protected ReferenceManager<IndexSearcher> mgr
-
globalStartNS
public static long globalStartNS
Startup time of original test, carefully propogated to all nodes to produce consistent "seconds since start time" in messages
-
localStartNS
public static final long localStartNS
When this node was started
-
printStream
protected final PrintStream printStream
For debug logging
-
lastFileMetaData
protected volatile Map<String,FileMetaData> lastFileMetaData
File metadata for last sync that succeeded; we use this as a cache
-
-
Constructor Detail
-
Node
public Node(int id, Directory dir, SearcherFactory searcherFactory, PrintStream printStream)
-
-
Method Detail
-
getSearcherManager
public ReferenceManager<IndexSearcher> getSearcherManager()
Returns theReferenceManagerto use for acquiring and releasing searchers
-
commit
public abstract void commit() throws IOException- Throws:
IOException
-
nodeMessage
public static void nodeMessage(PrintStream printStream, String message)
-
nodeMessage
public static void nodeMessage(PrintStream printStream, int id, String message)
-
message
public void message(String message)
-
name
public String name()
-
isClosed
public abstract boolean isClosed()
-
getCurrentSearchingVersion
public long getCurrentSearchingVersion() throws IOException- Throws:
IOException
-
bytesToString
public static String bytesToString(long bytes)
-
readLocalFileMetaData
public FileMetaData readLocalFileMetaData(String fileName) throws IOException
Opens the specified file, reads its identifying information, including file length, full index header (includes the unique segment ID) and the full footer (includes checksum), and returns the resultingFileMetaData.This returns null, logging a message, if there are any problems (the file does not exist, is corrupt, truncated, etc.).
- Throws:
IOException
-
-