Class 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 Detail

      • 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:
    • Method Detail

      • 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
      • 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
      • maybeNewPrimary

        protected void maybeNewPrimary​(long newPrimaryGen)
                                throws IOException
        Called when the primary changed
        Throws:
        IOException
      • startCopyFile

        public void startCopyFile​(String name)
      • finishCopyFile

        public void finishCopyFile​(String name)