Package org.opensearch.indices.recovery
Class RecoverySourceHandler
java.lang.Object
org.opensearch.indices.recovery.RecoverySourceHandler
- Direct Known Subclasses:
LocalStorePeerRecoverySourceHandler
,RemoteStorePeerRecoverySourceHandler
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.
- Opensearch.internal:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CancellableThreads
protected final ListenableFuture
<RecoveryResponse> protected final org.apache.logging.log4j.Logger
static final String
protected final StartRecoveryRequest
protected final IndexShard
protected final int
-
Method Summary
Modifier and TypeMethodDescriptionprotected GatedCloseable
<org.apache.lucene.index.IndexCommit> acquireSafeCommit
(IndexShard shard) Releasing a safe commit can access some commit files.protected org.opensearch.common.lease.Releasable
acquireStore
(Store store) Increases the store reference and returns aReleasable
that will decrease the store reference using the generic thread pool.void
addListener
(org.opensearch.core.action.ActionListener<RecoveryResponse> listener) void
Cancels the recovery and interrupts all eligible threads.protected int
countNumberOfHistoryOperations
(long startingSeqNo) Counts the number of history operations from the starting sequence numberprotected void
finalizeStepAndCompleteFuture
(long startingSeqNo, StepListener<org.opensearch.indices.recovery.RecoverySourceHandler.SendSnapshotResult> sendSnapshotStep, StepListener<org.opensearch.indices.recovery.RecoverySourceHandler.SendFileResult> sendFileStep, StepListener<org.opensearch.common.unit.TimeValue> prepareEngineStep, Consumer<Exception> onFailure) protected abstract void
innerRecoveryToTarget
(org.opensearch.core.action.ActionListener<RecoveryResponse> listener, Consumer<Exception> onFailure) protected boolean
protected void
onSendFileStepComplete
(StepListener<org.opensearch.indices.recovery.RecoverySourceHandler.SendFileResult> sendFileStep, GatedCloseable<org.apache.lucene.index.IndexCommit> wrappedSafeCommit, org.opensearch.common.lease.Releasable releaseStore) void
recoverToTarget
(org.opensearch.core.action.ActionListener<RecoveryResponse> listener) performs the recovery from the local engine to the targettoString()
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger -
shard
-
shardId
protected final int shardId -
request
-
cancellableThreads
-
resources
-
future
-
PEER_RECOVERY_NAME
- See Also:
-
-
Method Details
-
getRequest
-
addListener
-
recoverToTarget
performs the recovery from the local engine to the target -
innerRecoveryToTarget
protected abstract void innerRecoveryToTarget(org.opensearch.core.action.ActionListener<RecoveryResponse> listener, Consumer<Exception> onFailure) throws IOException - Throws:
IOException
-
finalizeStepAndCompleteFuture
protected void finalizeStepAndCompleteFuture(long startingSeqNo, StepListener<org.opensearch.indices.recovery.RecoverySourceHandler.SendSnapshotResult> sendSnapshotStep, StepListener<org.opensearch.indices.recovery.RecoverySourceHandler.SendFileResult> sendFileStep, StepListener<org.opensearch.common.unit.TimeValue> prepareEngineStep, Consumer<Exception> onFailure) -
onSendFileStepComplete
protected void onSendFileStepComplete(StepListener<org.opensearch.indices.recovery.RecoverySourceHandler.SendFileResult> sendFileStep, GatedCloseable<org.apache.lucene.index.IndexCommit> wrappedSafeCommit, org.opensearch.common.lease.Releasable releaseStore) -
isTargetSameHistory
protected boolean isTargetSameHistory() -
countNumberOfHistoryOperations
Counts the number of history operations from the starting sequence number- Parameters:
startingSeqNo
- the starting sequence number to count; included- Returns:
- number of history operations
- Throws:
IOException
-
acquireStore
Increases the store reference and returns aReleasable
that will decrease the store reference using the generic thread pool. We must never release the store using an interruptible thread as we can risk invalidating the node lock. -
acquireSafeCommit
Releasing a safe commit can access some commit files. It's better not to useCancellableThreads
to interact with the file systems due to interrupt (seeNIOFSDirectory
javadocs for more detail). This method acquires a safe commit and wraps it to make sure that it will be released using the generic thread pool. -
cancel
Cancels the recovery and interrupts all eligible threads. -
toString
-