Class RecoveriesCollection


  • public class RecoveriesCollection
    extends java.lang.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 Detail

      • RecoveriesCollection

        public RecoveriesCollection​(org.apache.logging.log4j.Logger logger,
                                    ThreadPool threadPool,
                                    java.util.function.LongConsumer ensureClusterStateVersionCallback)
    • Method Detail

      • 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

      • cancelRecovery

        public boolean cancelRecovery​(long id,
                                      java.lang.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
        Parameters:
        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,
                                                java.lang.String reason)
        cancel all ongoing recoveries for the given shard
        Parameters:
        reason - reason for cancellation
        shardId - shardId for which to cancel recoveries
        Returns:
        true if a recovery was cancelled