Class IndexReplicationHandler
A IReplicationHandler for replication of an index. Implements RevisionReady(String, IDictionary<String, IList<RevisionFile>>, IDictionary<String, IList<String>>, IDictionary<String, Directory>) by copying the files pointed by the client resolver to the index Directory and then touches the index with IndexWriter to make sure any unused files are deleted.
Inheritance
Assembly: Lucene.Net.Replicator.dll
Syntax
public class IndexReplicationHandler : object, IReplicationHandler
Remarks
NOTE: This handler assumes that IndexWriter is not opened by another process on the index directory. In fact, opening an IndexWriter on the same directory to which files are copied can lead to undefined behavior, where some or all the files will be deleted, override other files or simply create a mess. When you replicate an index, it is best if the index is never modified by IndexWriter, except the one that is open on the source index, from which you replicate.
This handler notifies the application via a provided
@lucene.experimental
Constructors
Name | Description |
---|---|
IndexReplicationHandler(Directory, Func<Nullable<Boolean>>) | Constructor with the given index directory and callback to notify when the indexes were updated. |
Fields
Name | Description |
---|---|
INFO_STREAM_COMPONENT | The component used to log messages to the Default InfoStream. |
Properties
Name | Description |
---|---|
CurrentRevisionFiles | |
CurrentVersion | |
InfoStream | Gets or sets the InfoStream to use for logging messages. |
Methods
Name | Description |
---|---|
CleanupFilesOnFailure(Directory, IList<String>) | Cleanup the index directory by deleting all given files. Called when file copy or sync failed. |
CleanupOldIndexFiles(Directory, String) | Cleans up the index directory from old index files. This method uses the
last commit found by GetLastCommit(Directory). If it matches the
expected |
CopyFiles(Directory, Directory, IList<String>) | Copies the provided list of files from the |
GetLastCommit(Directory) | Returns the last IndexCommit found in the Directory, or
|
GetSegmentsFile(IList<String>, Boolean) | Verifies that the last file is segments_N and fails otherwise. It also removes and returns the file from the list, because it needs to be handled last, after all files. This is important in order to guarantee that if a reader sees the new segments_N, all other segment files are already on stable storage. The reason why the code fails instead of putting segments_N file last is that this indicates an error in the IRevision implementation. |
RevisionReady(String, IDictionary<String, IList<RevisionFile>>, IDictionary<String, IList<String>>, IDictionary<String, Directory>) | |
WriteSegmentsGen(String, Directory) | Writes SEGMENTS_GEN file to the directory, reading
the generation from the given |