Class RecoveriesCollection
java.lang.Object
org.elasticsearch.indices.recovery.RecoveriesCollection
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.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
a reference toRecoveryTarget
, which implementsAutoCloseable
. -
Constructor Summary
ConstructorDescriptionRecoveriesCollection
(org.apache.logging.log4j.Logger logger, ThreadPool threadPool) -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancelRecoveriesForShard
(ShardId shardId, String reason) cancel all ongoing recoveries for the given shardboolean
cancelRecovery
(long id, String reason) cancel the recovery with the given id (if found) and remove it from the recovery collectionvoid
failRecovery
(long id, RecoveryFailedException e, boolean sendShardFailure) fail the recovery with the given id (if found) and remove it from the recovery collectiongetRecovery
(long id) gets theRecoveryTarget
for a given id.getRecoverySafe
(long id, ShardId shardId) Similar togetRecovery(long)
but throws an exception if no recovery is foundgetRecoveryTarget
(long id) void
markRecoveryAsDone
(long id) mark the recovery with the given id as done (if found)resetRecovery
(long recoveryId, TimeValue activityTimeout) Resets the recovery and performs a recovery restart on the currently recovering index shardint
size()
the number of ongoing recoverieslong
startRecovery
(IndexShard indexShard, DiscoveryNode sourceNode, SnapshotFilesProvider snapshotFilesProvider, PeerRecoveryTargetService.RecoveryListener listener, TimeValue activityTimeout, Releasable snapshotFileDownloadsPermit) Starts are new recovery for the given shard, source node and state
-
Constructor Details
-
RecoveriesCollection
-
-
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- Returns:
- the id of the new recovery.
-
resetRecovery
Resets the recovery and performs a recovery restart on the currently recovering index shard- Returns:
- newly created RecoveryTarget
- See Also:
-
getRecoveryTarget
-
getRecovery
gets theRecoveryTarget
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 callAbstractRefCounted.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
Similar togetRecovery(long)
but throws an exception if no recovery is found -
cancelRecovery
cancel the recovery with the given id (if found) and remove it from the recovery collection -
failRecovery
fail the recovery with the given id (if found) and remove it from the recovery collection- Parameters:
id
- id of the recovery to faile
- exception with reason for the failuresendShardFailure
- 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
cancel all ongoing recoveries for the given shard- Parameters:
reason
- reason for cancellationshardId
- shardId for which to cancel recoveries- Returns:
- true if a recovery was cancelled
-