Class RecoverySourceHandler
- java.lang.Object
-
- org.elasticsearch.indices.recovery.RecoverySourceHandler
-
public class RecoverySourceHandler extends java.lang.ObjectRecoverySourceHandler 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 theRateLimiterpassed viaRecoverySettingsis 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.
-
-
Constructor Summary
Constructors Constructor Description RecoverySourceHandler(IndexShard shard, RecoveryTargetHandler recoveryTarget, StartRecoveryRequest request, int fileChunkSizeInBytes, Settings nodeSettings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel(java.lang.String reason)Cancels the recovery and interrupts all eligible threads.protected voidfailEngine(java.io.IOException cause)voidfinalizeRecovery(long targetLocalCheckpoint)StartRecoveryRequestgetRequest()voidphase1(org.apache.lucene.index.IndexCommit snapshot, java.util.function.Supplier<java.lang.Integer> translogOps)Perform phase1 of the recovery operations.org.elasticsearch.indices.recovery.RecoveryResponserecoverToTarget()performs the recovery from the local engine to the targetprotected org.elasticsearch.indices.recovery.RecoverySourceHandler.SendSnapshotResultsendSnapshot(long startingSeqNo, long requiredSeqNoRangeStart, long endingSeqNo, Translog.Snapshot snapshot)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.StringtoString()
-
-
-
Constructor Detail
-
RecoverySourceHandler
public RecoverySourceHandler(IndexShard shard, RecoveryTargetHandler recoveryTarget, StartRecoveryRequest request, int fileChunkSizeInBytes, Settings nodeSettings)
-
-
Method Detail
-
getRequest
public StartRecoveryRequest getRequest()
-
recoverToTarget
public org.elasticsearch.indices.recovery.RecoveryResponse recoverToTarget() throws java.io.IOExceptionperforms 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 thisIndexCommitsnapshot has been performed no commit operations (files being fsync'd) are effectively allowed on this index until all recovery phases are donePhase1 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) throws java.io.IOExceptionSend 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 sentrequiredSeqNoRangeStart- the lower sequence number of the required rangeendingSeqNo- 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- 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:
toStringin classjava.lang.Object
-
failEngine
protected void failEngine(java.io.IOException cause)
-
-