Class ReplicationCollection<T extends ReplicationTarget>
java.lang.Object
org.opensearch.indices.replication.common.ReplicationCollection<T>
This class holds a collection of all on going replication events on the current node (i.e., the node is the target node
of those events). The class is used to guarantee concurrent semantics such that once an event was done/cancelled/failed
no other thread will be able to find it. Last, the
ReplicationCollection.ReplicationRef
inner class verifies that temporary files
and store will only be cleared once on going usage is finished.- Opensearch.internal:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
a reference toReplicationTarget
, which implementsAutoCloseable
. -
Constructor Summary
ConstructorsConstructorDescriptionReplicationCollection
(org.apache.logging.log4j.Logger logger, ThreadPool threadPool) -
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel the target with the given id (if found) and remove it from the target collectionboolean
cancelForShard
(ShardId shardId, String reason) cancel all ongoing targets for the given shardvoid
fail
(long id, OpenSearchException e, boolean sendShardFailure) fail the target with the given id (if found) and remove it from the target collectionget
(long id) gets theReplicationTarget
for a given id.Similar toget(long)
but throws an exception if no target is foundgetTarget
(long id) void
markAsDone
(long id) mark the target with the given id as done (if found)reset
(long id, org.opensearch.common.unit.TimeValue activityTimeout) Resets the target event and performs a restart on the current index shardint
size()
the number of ongoing target eventslong
Starts a new target event for the given shard, source node and state
-
Constructor Details
-
ReplicationCollection
-
-
Method Details
-
start
Starts a new target event for the given shard, source node and state- Returns:
- the id of the new target event.
-
reset
Resets the target event and performs a restart on the current index shard- Returns:
- newly created Target
- See Also:
-
getTarget
-
get
gets theReplicationTarget
for a given id. The ShardTarget 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 target event is not found
-
getSafe
Similar toget(long)
but throws an exception if no target is found -
cancel
cancel the target with the given id (if found) and remove it from the target collection -
fail
fail the target with the given id (if found) and remove it from the target collection- Parameters:
id
- id of the target to faile
- exception with reason for the failuresendShardFailure
- true a shard failed message should be sent to the master
-
markAsDone
public void markAsDone(long id) mark the target with the given id as done (if found) -
size
public int size()the number of ongoing target events -
cancelForShard
cancel all ongoing targets for the given shard- Parameters:
reason
- reason for cancellationshardId
- shardId for which to cancel targets- Returns:
- true if a target was cancelled
-