Class RecoverySourceHandler

java.lang.Object
org.opensearch.indices.recovery.RecoverySourceHandler
Direct Known Subclasses:
LocalStorePeerRecoverySourceHandler, RemoteStorePeerRecoverySourceHandler

public abstract class RecoverySourceHandler extends 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.

Opensearch.internal:
  • Field Details

  • Method Details

    • getRequest

      public StartRecoveryRequest getRequest()
    • addListener

      public void addListener(org.opensearch.core.action.ActionListener<RecoveryResponse> listener)
    • recoverToTarget

      public void recoverToTarget(org.opensearch.core.action.ActionListener<RecoveryResponse> listener)
      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

      protected int countNumberOfHistoryOperations(long startingSeqNo) throws IOException
      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

      protected org.opensearch.common.lease.Releasable acquireStore(Store store)
      Increases the store reference and returns a Releasable 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

      protected GatedCloseable<org.apache.lucene.index.IndexCommit> acquireSafeCommit(IndexShard shard)
      Releasing a safe commit can access some commit files. It's better not to use CancellableThreads to interact with the file systems due to interrupt (see NIOFSDirectory 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

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

      public String toString()
      Overrides:
      toString in class Object