Class RecoverySourceHandler


  • public class RecoverySourceHandler
    extends java.lang.Object
    RecoverySourceHandler handles the three phases of shard recovery, which is everything relating to copying the segment files as well as sending translog operations across the wire once the segments have been copied. Note: There is always one source handler per recovery that handles all the file and translog transfer. This handler is completely isolated from other recoveries while the RateLimiter passed via RecoverySettings is shared across recoveries originating from this nodes to throttle the number bytes send during file transfer. The transaction log phase bypasses the rate limiter entirely.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.logging.log4j.Logger logger  
      protected org.elasticsearch.indices.recovery.RecoveryResponse response  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel​(java.lang.String reason)
      Cancels the recovery and interrupts all eligible threads.
      protected void failEngine​(java.io.IOException cause)  
      void finalizeRecovery​(long targetLocalCheckpoint)  
      StartRecoveryRequest getRequest()  
      void phase1​(org.apache.lucene.index.IndexCommit snapshot, java.util.function.Supplier<java.lang.Integer> translogOps)
      Perform phase1 of the recovery operations.
      org.elasticsearch.indices.recovery.RecoveryResponse recoverToTarget()
      performs the recovery from the local engine to the target
      protected org.elasticsearch.indices.recovery.RecoverySourceHandler.SendSnapshotResult sendSnapshot​(long startingSeqNo, long requiredSeqNoRangeStart, long endingSeqNo, Translog.Snapshot snapshot, long maxSeenAutoIdTimestamp, long maxSeqNoOfUpdatesOrDeletes)
      Send the given snapshot's operations with a sequence number greater than the specified staring sequence number to this handler's target node.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • logger

        protected final org.apache.logging.log4j.Logger logger
      • response

        protected final org.elasticsearch.indices.recovery.RecoveryResponse response
    • Method Detail

      • recoverToTarget

        public org.elasticsearch.indices.recovery.RecoveryResponse recoverToTarget()
                                                                            throws java.io.IOException
        performs the recovery from the local engine to the target
        Throws:
        java.io.IOException
      • phase1

        public void phase1​(org.apache.lucene.index.IndexCommit snapshot,
                           java.util.function.Supplier<java.lang.Integer> translogOps)
        Perform phase1 of the recovery operations. Once this IndexCommit snapshot has been performed no commit operations (files being fsync'd) are effectively allowed on this index until all recovery phases are done

        Phase1 examines the segment files on the target node and copies over the segments that are missing. Only segments that have the same size and checksum can be reused

      • finalizeRecovery

        public void finalizeRecovery​(long targetLocalCheckpoint)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • sendSnapshot

        protected org.elasticsearch.indices.recovery.RecoverySourceHandler.SendSnapshotResult sendSnapshot​(long startingSeqNo,
                                                                                                           long requiredSeqNoRangeStart,
                                                                                                           long endingSeqNo,
                                                                                                           Translog.Snapshot snapshot,
                                                                                                           long maxSeenAutoIdTimestamp,
                                                                                                           long maxSeqNoOfUpdatesOrDeletes)
                                                                                                    throws java.io.IOException
        Send the given snapshot's operations with a sequence number greater than the specified staring sequence number to this handler's target node.

        Operations are bulked into a single request depending on an operation count limit or size-in-bytes limit.

        Parameters:
        startingSeqNo - the sequence number for which only operations with a sequence number greater than this will be sent
        requiredSeqNoRangeStart - the lower sequence number of the required range
        endingSeqNo - the upper bound of the sequence number range to be sent (inclusive)
        snapshot - the translog snapshot to replay operations from @return the local checkpoint on the target and the total number of operations sent
        maxSeenAutoIdTimestamp - the max auto_id_timestamp of append-only requests on the primary
        maxSeqNoOfUpdatesOrDeletes - the max seq_no of updates or deletes on the primary after these operations were executed on it.
        Throws:
        java.io.IOException - if an I/O exception occurred reading the translog snapshot
      • cancel

        public void cancel​(java.lang.String reason)
        Cancels the recovery and interrupts all eligible threads.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • failEngine

        protected void failEngine​(java.io.IOException cause)