Class TransportReplicationAction<Request extends ReplicationRequest<Request>,ReplicaRequest extends ReplicationRequest<ReplicaRequest>,Response extends ReplicationResponse>
java.lang.Object
org.elasticsearch.action.support.TransportAction<Request,Response>
org.elasticsearch.action.support.replication.TransportReplicationAction<Request,ReplicaRequest,Response>
- Direct Known Subclasses:
GlobalCheckpointSyncAction
,RetentionLeaseBackgroundSyncAction
,TransportShardFlushAction
,TransportShardRefreshAction
,TransportVerifyShardBeforeCloseAction
,TransportVerifyShardIndexBlockAction
,TransportWriteAction
public abstract class TransportReplicationAction<Request extends ReplicationRequest<Request>,ReplicaRequest extends ReplicationRequest<ReplicaRequest>,Response extends ReplicationResponse>
extends TransportAction<Request,Response>
Base class for requests that should be executed on a primary copy followed by replica copies.
Subclasses can resolve the target shard and provide implementation for primary and replica operations.
The action samples cluster state on the receiving node to reroute to node with primary copy and on the
primary node to validate request before primary operation followed by sampling state again for resolving
nodes with replica copies to perform replication.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
static class
a wrapper class to encapsulate a request when being sent to a specific allocation idstatic class
TransportReplicationAction.PrimaryResult<ReplicaRequest extends ReplicationRequest<ReplicaRequest>,Response extends ReplicationResponse>
static class
static class
protected class
TheReplicasProxy
is an implementation of theReplicas
interface that performs the actualReplicaRequest
on the replica shards.static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected ClusterService
protected String
protected boolean
protected IndicesService
static Setting<org.elasticsearch.core.TimeValue>
The maximum bound for the first retry backoff for failed replication operations.static Setting<org.elasticsearch.core.TimeValue>
The timeout for retrying replication requests.protected ShardStateAction
protected ThreadPool
protected TransportRequestOptions
protected String
protected String
protected TransportService
Fields inherited from class org.elasticsearch.action.support.TransportAction
actionName, localConnection, logger, taskManager
-
Constructor Summary
ModifierConstructorDescriptionprotected
TransportReplicationAction(Settings settings, String actionName, TransportService transportService, ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, ActionFilters actionFilters, Writeable.Reader<Request> requestReader, Writeable.Reader<ReplicaRequest> replicaRequestReader, String executor)
protected
TransportReplicationAction(Settings settings, String actionName, TransportService transportService, ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, ActionFilters actionFilters, Writeable.Reader<Request> requestReader, Writeable.Reader<ReplicaRequest> replicaRequestReader, String executor, boolean syncGlobalCheckpointAfterOperation, boolean forceExecutionOnPrimary)
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
acquirePrimaryOperationPermit(IndexShard primary, Request request, ActionListener<org.elasticsearch.core.Releasable> onAcquired)
Executes the logic for acquiring one or more operation permit on a primary shard.protected void
acquireReplicaOperationPermit(IndexShard replica, ReplicaRequest request, ActionListener<org.elasticsearch.core.Releasable> onAcquired, long primaryTerm, long globalCheckpoint, long maxSeqNoOfUpdatesOrDeletes)
Executes the logic for acquiring one or more operation permit on a replica shard.protected void
adaptResponse(Response response, IndexShard indexShard)
protected org.elasticsearch.core.Releasable
checkOperationLimits(Request request)
protected org.elasticsearch.core.Releasable
checkPrimaryLimits(Request request, boolean rerouteWasLocal, boolean localRerouteInitiatedByNodeClient)
protected org.elasticsearch.core.Releasable
checkReplicaLimits(ReplicaRequest request)
protected void
doExecute(Task task, Request request, ActionListener<Response> listener)
protected ClusterBlockLevel
Cluster level block to check before request execution.protected void
handlePrimaryRequest(TransportReplicationAction.ConcreteShardRequest<Request> request, TransportChannel channel, Task task)
protected void
handleReplicaRequest(TransportReplicationAction.ConcreteReplicaRequest<ReplicaRequest> replicaRequest, TransportChannel channel, Task task)
Index level block to check before request execution.protected ReplicationOperation.Replicas<ReplicaRequest>
protected abstract Response
protected void
resolveRequest(IndexMetadata indexMetadata, Request request)
Resolves derived values in the request.protected boolean
protected abstract void
shardOperationOnPrimary(Request shardRequest, IndexShard primary, ActionListener<TransportReplicationAction.PrimaryResult<ReplicaRequest,Response>> listener)
Primary operation on node with primary copy.protected abstract void
shardOperationOnReplica(ReplicaRequest shardRequest, IndexShard replica, ActionListener<TransportReplicationAction.ReplicaResult> listener)
Execute the specified replica operation.protected TransportRequestOptions
Methods inherited from class org.elasticsearch.action.support.TransportAction
execute, execute, execute
-
Field Details
-
REPLICATION_RETRY_TIMEOUT
The timeout for retrying replication requests. -
REPLICATION_INITIAL_RETRY_BACKOFF_BOUND
public static final Setting<org.elasticsearch.core.TimeValue> REPLICATION_INITIAL_RETRY_BACKOFF_BOUNDThe maximum bound for the first retry backoff for failed replication operations. The backoff bound will increase exponential if failures continue. -
threadPool
-
transportService
-
clusterService
-
shardStateAction
-
indicesService
-
transportOptions
-
executor
-
forceExecutionOnPrimary
protected final boolean forceExecutionOnPrimary -
transportReplicaAction
-
transportPrimaryAction
-
-
Constructor Details
-
TransportReplicationAction
protected TransportReplicationAction(Settings settings, String actionName, TransportService transportService, ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, ActionFilters actionFilters, Writeable.Reader<Request> requestReader, Writeable.Reader<ReplicaRequest> replicaRequestReader, String executor) -
TransportReplicationAction
protected TransportReplicationAction(Settings settings, String actionName, TransportService transportService, ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, ActionFilters actionFilters, Writeable.Reader<Request> requestReader, Writeable.Reader<ReplicaRequest> replicaRequestReader, String executor, boolean syncGlobalCheckpointAfterOperation, boolean forceExecutionOnPrimary)
-
-
Method Details
-
doExecute
- Specified by:
doExecute
in classTransportAction<Request extends ReplicationRequest<Request>,Response extends ReplicationResponse>
-
newReplicasProxy
-
newResponseInstance
- Throws:
IOException
-
resolveRequest
Resolves derived values in the request. For example, the target shard id of the incoming request, if not set at request construction. Additional processing or validation of the request should be done here.- Parameters:
indexMetadata
- index metadata of the concrete index this request is going to operate onrequest
- the request to resolve
-
shardOperationOnPrimary
protected abstract void shardOperationOnPrimary(Request shardRequest, IndexShard primary, ActionListener<TransportReplicationAction.PrimaryResult<ReplicaRequest,Response>> listener)Primary operation on node with primary copy.- Parameters:
shardRequest
- the request to the primary shardprimary
- the primary shard to perform the operation on
-
shardOperationOnReplica
protected abstract void shardOperationOnReplica(ReplicaRequest shardRequest, IndexShard replica, ActionListener<TransportReplicationAction.ReplicaResult> listener)Execute the specified replica operation. This is done under a permit fromIndexShard.acquireReplicaOperationPermit(long, long, long, ActionListener, String, Object)
.- Parameters:
shardRequest
- the request to the replica shardreplica
- the replica shard to perform the operation on
-
globalBlockLevel
Cluster level block to check before request execution. Returning null means that no blocks need to be checked. -
indexBlockLevel
Index level block to check before request execution. Returning null means that no blocks need to be checked. -
transportOptions
-
retryPrimaryException
-
checkOperationLimits
-
handlePrimaryRequest
protected void handlePrimaryRequest(TransportReplicationAction.ConcreteShardRequest<Request> request, TransportChannel channel, Task task) -
checkPrimaryLimits
protected org.elasticsearch.core.Releasable checkPrimaryLimits(Request request, boolean rerouteWasLocal, boolean localRerouteInitiatedByNodeClient) -
adaptResponse
-
handleReplicaRequest
protected void handleReplicaRequest(TransportReplicationAction.ConcreteReplicaRequest<ReplicaRequest> replicaRequest, TransportChannel channel, Task task) -
checkReplicaLimits
-
acquirePrimaryOperationPermit
protected void acquirePrimaryOperationPermit(IndexShard primary, Request request, ActionListener<org.elasticsearch.core.Releasable> onAcquired)Executes the logic for acquiring one or more operation permit on a primary shard. The default is to acquire a single permit but this method can be overridden to acquire more. -
acquireReplicaOperationPermit
protected void acquireReplicaOperationPermit(IndexShard replica, ReplicaRequest request, ActionListener<org.elasticsearch.core.Releasable> onAcquired, long primaryTerm, long globalCheckpoint, long maxSeqNoOfUpdatesOrDeletes)Executes the logic for acquiring one or more operation permit on a replica shard. The default is to acquire a single permit but this method can be overridden to acquire more.
-