protected class TransportReplicationAction.ReplicasProxy extends java.lang.Object implements ReplicationOperation.Replicas<ReplicaRequest>
ReplicasProxy
is an implementation of the Replicas
interface that performs the actual ReplicaRequest
on the replica
shards. It also encapsulates the logic required for failing the replica
if deemed necessary as well as marking it as stale when needed.Modifier and Type | Field and Description |
---|---|
protected long |
primaryTerm |
Constructor and Description |
---|
ReplicasProxy(long primaryTerm) |
Modifier and Type | Method and Description |
---|---|
void |
failShardIfNeeded(ShardRouting replica,
java.lang.String message,
java.lang.Exception exception,
java.lang.Runnable onSuccess,
java.util.function.Consumer<java.lang.Exception> onPrimaryDemoted,
java.util.function.Consumer<java.lang.Exception> onIgnoredFailure)
Fail the specified shard if needed, removing it from the current set
of active shards.
|
void |
markShardCopyAsStaleIfNeeded(ShardId shardId,
java.lang.String allocationId,
java.lang.Runnable onSuccess,
java.util.function.Consumer<java.lang.Exception> onPrimaryDemoted,
java.util.function.Consumer<java.lang.Exception> onIgnoredFailure)
Marks shard copy as stale if needed, removing its allocation id from
the set of in-sync allocation ids.
|
void |
performOn(ShardRouting replica,
ReplicaRequest request,
long globalCheckpoint,
ActionListener<ReplicationOperation.ReplicaResponse> listener)
Performs the specified request on the specified replica.
|
public void performOn(ShardRouting replica, ReplicaRequest request, long globalCheckpoint, ActionListener<ReplicationOperation.ReplicaResponse> listener)
ReplicationOperation.Replicas
performOn
in interface ReplicationOperation.Replicas<ReplicaRequest extends ReplicationRequest<ReplicaRequest>>
replica
- the shard this request should be executed onrequest
- the operation to performglobalCheckpoint
- the global checkpoint on the primarylistener
- callback for handling the response or failurepublic void failShardIfNeeded(ShardRouting replica, java.lang.String message, java.lang.Exception exception, java.lang.Runnable onSuccess, java.util.function.Consumer<java.lang.Exception> onPrimaryDemoted, java.util.function.Consumer<java.lang.Exception> onIgnoredFailure)
ReplicationOperation.Replicas
failShardIfNeeded
in interface ReplicationOperation.Replicas<ReplicaRequest extends ReplicationRequest<ReplicaRequest>>
replica
- shard to failmessage
- a (short) description of the reasonexception
- the original exception which caused the ReplicationOperation to request the shard to be failedonSuccess
- a callback to call when the shard has been successfully removed from the active set.onPrimaryDemoted
- a callback to call when the shard can not be failed because the current primary has been demoted
by the master.onIgnoredFailure
- a callback to call when failing a shard has failed, but it that failure can be safely ignored and thepublic void markShardCopyAsStaleIfNeeded(ShardId shardId, java.lang.String allocationId, java.lang.Runnable onSuccess, java.util.function.Consumer<java.lang.Exception> onPrimaryDemoted, java.util.function.Consumer<java.lang.Exception> onIgnoredFailure)
ReplicationOperation.Replicas
markShardCopyAsStaleIfNeeded
in interface ReplicationOperation.Replicas<ReplicaRequest extends ReplicationRequest<ReplicaRequest>>
shardId
- shard idallocationId
- allocation id to remove from the set of in-sync allocation idsonSuccess
- a callback to call when the allocation id has been successfully removed from the in-sync set.onPrimaryDemoted
- a callback to call when the request failed because the current primary was already demoted
by the master.onIgnoredFailure
- a callback to call when the request failed, but the failure can be safely ignored.