Class RecoveriesCollection


public class RecoveriesCollection extends Object
This class holds a collection of all on going recoveries on the current node (i.e., the node is the target node of those recoveries). The class is used to guarantee concurrent semantics such that once a recoveries was done/cancelled/failed no other thread will be able to find it. Last, the RecoveriesCollection.RecoveryRef inner class verifies that recovery temporary files and store will only be cleared once on going usage is finished.
  • Constructor Details

    • RecoveriesCollection

      public RecoveriesCollection(org.apache.logging.log4j.Logger logger, ThreadPool threadPool)
  • Method Details

    • startRecovery

      public long startRecovery(IndexShard indexShard, DiscoveryNode sourceNode, SnapshotFilesProvider snapshotFilesProvider, PeerRecoveryTargetService.RecoveryListener listener, TimeValue activityTimeout, @Nullable Releasable snapshotFileDownloadsPermit)
      Starts are new recovery for the given shard, source node and state
      the id of the new recovery.
    • resetRecovery

      public RecoveryTarget resetRecovery(long recoveryId, TimeValue activityTimeout)
      Resets the recovery and performs a recovery restart on the currently recovering index shard
      newly created RecoveryTarget
      See Also:
    • getRecoveryTarget

      public RecoveryTarget getRecoveryTarget(long id)
    • getRecovery

      public RecoveriesCollection.RecoveryRef getRecovery(long id)
      gets the RecoveryTarget for a given id. The RecoveryStatus returned has it's ref count already incremented to make sure it's safe to use. However, you must call AbstractRefCounted.decRef() when you are done with it, typically by using this method in a try-with-resources clause.

      Returns null if recovery is not found

    • getRecoverySafe

      public RecoveriesCollection.RecoveryRef getRecoverySafe(long id, ShardId shardId)
      Similar to getRecovery(long) but throws an exception if no recovery is found
    • cancelRecovery

      public boolean cancelRecovery(long id, String reason)
      cancel the recovery with the given id (if found) and remove it from the recovery collection
    • failRecovery

      public void failRecovery(long id, RecoveryFailedException e, boolean sendShardFailure)
      fail the recovery with the given id (if found) and remove it from the recovery collection
      id - id of the recovery to fail
      e - exception with reason for the failure
      sendShardFailure - true a shard failed message should be sent to the master
    • markRecoveryAsDone

      public void markRecoveryAsDone(long id)
      mark the recovery with the given id as done (if found)
    • size

      public int size()
      the number of ongoing recoveries
    • cancelRecoveriesForShard

      public boolean cancelRecoveriesForShard(ShardId shardId, String reason)
      cancel all ongoing recoveries for the given shard
      reason - reason for cancellation
      shardId - shardId for which to cancel recoveries
      true if a recovery was cancelled