Package org.apache.lucene.replicator.nrt
Class ReplicaNode
java.lang.Object
org.apache.lucene.replicator.nrt.Node
org.apache.lucene.replicator.nrt.ReplicaNode
- All Implemented Interfaces:
Closeable
,AutoCloseable
Replica node, that pulls index changes from the primary node by copying newly flushed or merged
index files.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Field Summary
Modifier and TypeFieldDescriptionprotected CopyJob
Non-null when we are currently copying files from a new NRT point:protected final Collection<String>
IncRef'd files in the current NRT point:protected long
Primary gen last time we successfully replicated:Currently running merge pre-copy jobsFields inherited from class org.apache.lucene.replicator.nrt.Node
dir, globalStartNS, id, lastFileMetaData, localStartNS, mgr, PRIMARY_GEN_KEY, printStream, searcherFactory, VERBOSE_CONNECTIONS, VERBOSE_FILES, VERSION_KEY
-
Constructor Summary
ConstructorDescriptionReplicaNode
(int id, Directory dir, SearcherFactory searcherFactory, PrintStream printStream) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
commit()
createTempOutput
(String prefix, String suffix, IOContext ioContext) void
finishCopyFile
(String name) protected void
finishNRTCopy
(CopyJob job, long startNS) getFilesToCopy
(Map<String, FileMetaData> files) Compares incoming per-file identity (id, checksum, header, footer) versus what we have locally and returns the subset of the incoming files that need copyingboolean
isClosed()
boolean
protected abstract void
Runs this job async'dprotected CopyJob
launchPreCopyMerge
(AtomicBoolean finished, long newPrimaryGen, Map<String, FileMetaData> files) protected void
maybeNewPrimary
(long newPrimaryGen) Called when the primary changedprotected abstract CopyJob
newCopyJob
(String reason, Map<String, FileMetaData> files, Map<String, FileMetaData> prevFiles, boolean highPriority, CopyJob.OnceDone onceDone) Start a background copying job, to copy the specified files from the current primary node.newNRTPoint
(long newPrimaryGen, long version) Call this to notify this replica node that a new NRT infos is available on the primary.protected abstract void
Tell primary we (replica) just started, so primary can tell us to warm any already warming merges.protected void
start
(long curPrimaryGen) Start up this replica, which possibly requires heavy copying of files from the primary node, if we were down for a long timevoid
startCopyFile
(String name) Methods inherited from class org.apache.lucene.replicator.nrt.Node
bytesToString, getCurrentSearchingVersion, getDirectory, getSearcherManager, message, name, nodeMessage, nodeMessage, readLocalFileMetaData, toString
-
Field Details
-
lastNRTFiles
IncRef'd files in the current NRT point: -
mergeCopyJobs
Currently running merge pre-copy jobs -
curNRTCopy
Non-null when we are currently copying files from a new NRT point: -
lastPrimaryGen
protected long lastPrimaryGenPrimary gen last time we successfully replicated:
-
-
Constructor Details
-
ReplicaNode
public ReplicaNode(int id, Directory dir, SearcherFactory searcherFactory, PrintStream printStream) throws IOException - Throws:
IOException
-
-
Method Details
-
start
Start up this replica, which possibly requires heavy copying of files from the primary node, if we were down for a long time- Throws:
IOException
-
commit
- Specified by:
commit
in classNode
- Throws:
IOException
-
finishNRTCopy
- Throws:
IOException
-
newCopyJob
protected abstract CopyJob newCopyJob(String reason, Map<String, FileMetaData> files, Map<String, throws IOExceptionFileMetaData> prevFiles, boolean highPriority, CopyJob.OnceDone onceDone) Start a background copying job, to copy the specified files from the current primary node. If files is null then the latest copy state should be copied. If prevJob is not null, then the new copy job is replacing it and should 1) cancel the previous one, and 2) optionally salvage e.g. partially copied and, shared with the new copy job, files.- Throws:
IOException
-
launch
Runs this job async'd -
sendNewReplica
Tell primary we (replica) just started, so primary can tell us to warm any already warming merges. This lets us keep low nrt refresh time for the first nrt sync after we started.- Throws:
IOException
-
newNRTPoint
Call this to notify this replica node that a new NRT infos is available on the primary. We kick off a job (runs in the background) to copy files across, and open a new reader once that's done.- Throws:
IOException
-
isCopying
public boolean isCopying() -
isClosed
public boolean isClosed() -
close
- Throws:
IOException
-
maybeNewPrimary
Called when the primary changed- Throws:
IOException
-
launchPreCopyMerge
protected CopyJob launchPreCopyMerge(AtomicBoolean finished, long newPrimaryGen, Map<String, FileMetaData> files) throws IOException- Throws:
IOException
-
createTempOutput
public IndexOutput createTempOutput(String prefix, String suffix, IOContext ioContext) throws IOException - Throws:
IOException
-
getFilesToCopy
public List<Map.Entry<String,FileMetaData>> getFilesToCopy(Map<String, FileMetaData> files) throws IOExceptionCompares incoming per-file identity (id, checksum, header, footer) versus what we have locally and returns the subset of the incoming files that need copying- Throws:
IOException
-
startCopyFile
-
finishCopyFile
-