Class ReplicaNode

java.lang.Object
org.apache.lucene.replicator.nrt.Node
org.apache.lucene.replicator.nrt.ReplicaNode
All Implemented Interfaces:
Closeable, AutoCloseable

public abstract class ReplicaNode extends Node
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 Details

    • lastNRTFiles

      protected final Collection<String> lastNRTFiles
      IncRef'd files in the current NRT point:
    • mergeCopyJobs

      protected final Set<CopyJob> mergeCopyJobs
      Currently running merge pre-copy jobs
    • curNRTCopy

      protected CopyJob curNRTCopy
      Non-null when we are currently copying files from a new NRT point:
    • lastPrimaryGen

      protected long lastPrimaryGen
      Primary gen last time we successfully replicated:
  • Constructor Details

  • Method Details

    • start

      protected void start(long curPrimaryGen) throws IOException
      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

      public void commit() throws IOException
      Specified by:
      commit in class Node
      Throws:
      IOException
    • finishNRTCopy

      protected void finishNRTCopy(CopyJob job, long startNS) throws IOException
      Throws:
      IOException
    • newCopyJob

      protected abstract CopyJob newCopyJob(String reason, Map<String,FileMetaData> files, Map<String,FileMetaData> prevFiles, boolean highPriority, CopyJob.OnceDone onceDone) throws IOException
      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

      protected abstract void launch(CopyJob job)
      Runs this job async'd
    • sendNewReplica

      protected abstract void sendNewReplica() throws IOException
      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

      public CopyJob newNRTPoint(long newPrimaryGen, long version) throws IOException
      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()
      Specified by:
      isClosed in class Node
    • close

      public void close() throws IOException
      Throws:
      IOException
    • maybeNewPrimary

      protected void maybeNewPrimary(long newPrimaryGen) throws IOException
      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 IOException
      Compares 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

      public void startCopyFile(String name)
    • finishCopyFile

      public void finishCopyFile(String name)