Class TransportWriteAction<Request extends ReplicatedWriteRequest<Request>,ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse>
- java.lang.Object
-
- org.elasticsearch.common.component.AbstractComponent
-
- org.elasticsearch.action.support.TransportAction<Request,Response>
-
- org.elasticsearch.action.support.replication.TransportReplicationAction<Request,ReplicaRequest,Response>
-
- org.elasticsearch.action.support.replication.TransportWriteAction<Request,ReplicaRequest,Response>
-
- Direct Known Subclasses:
TransportResyncReplicationAction
,TransportShardBulkAction
,TransportSingleItemBulkWriteAction
public abstract class TransportWriteAction<Request extends ReplicatedWriteRequest<Request>,ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse> extends TransportReplicationAction<Request,ReplicaRequest,Response>
Base class for transport actions that modify data in some shard like index, delete, and shardBulk. Allows performing async actions (e.g. refresh) after performing write operations on primary and replica shards
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TransportWriteAction.WritePrimaryResult<ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse>
Result of taking the action on the primary.protected static class
TransportWriteAction.WriteReplicaResult<ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>>
Result of taking the action on the replica.-
Nested classes/interfaces inherited from class org.elasticsearch.action.support.replication.TransportReplicationAction
TransportReplicationAction.ConcreteReplicaRequest<R extends TransportRequest>, TransportReplicationAction.ConcreteShardRequest<R extends TransportRequest>, TransportReplicationAction.OperationTransportHandler, TransportReplicationAction.PrimaryOperationTransportHandler, TransportReplicationAction.PrimaryResult<ReplicaRequest extends ReplicationRequest<ReplicaRequest>,Response extends ReplicationResponse>, TransportReplicationAction.ReplicaOperationTransportHandler, TransportReplicationAction.ReplicaResponse, TransportReplicationAction.ReplicaResult, TransportReplicationAction.ReplicasProxy, TransportReplicationAction.RetryOnReplicaException
-
-
Field Summary
-
Fields inherited from class org.elasticsearch.action.support.replication.TransportReplicationAction
clusterService, executor, indexNameExpressionResolver, indicesService, shardStateAction, threadPool, transportOptions, transportPrimaryAction, transportReplicaAction, transportService
-
Fields inherited from class org.elasticsearch.action.support.TransportAction
actionName, taskManager
-
Fields inherited from class org.elasticsearch.common.component.AbstractComponent
logger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TransportWriteAction(Settings settings, java.lang.String actionName, TransportService transportService, ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, java.util.function.Supplier<Request> request, java.util.function.Supplier<ReplicaRequest> replicaRequest, java.lang.String executor)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ClusterBlockLevel
globalBlockLevel()
Cluster level block to check before request execution.protected ClusterBlockLevel
indexBlockLevel()
Index level block to check before request execution.static Translog.Location
locationToSync(Translog.Location current, Translog.Location next)
protected ReplicationOperation.Replicas
newReplicasProxy(long primaryTerm)
protected abstract TransportWriteAction.WritePrimaryResult<ReplicaRequest,Response>
shardOperationOnPrimary(Request request, IndexShard primary)
Called on the primary with a reference to the primary IndexShard to modify.protected abstract TransportWriteAction.WriteReplicaResult<ReplicaRequest>
shardOperationOnReplica(ReplicaRequest request, IndexShard replica)
Called once per replica with a reference to the replica IndexShard to modify.protected static Translog.Location
syncOperationResultOrThrow(Engine.Result operationResult, Translog.Location currentLocation)
Syncs operation result to the translog or throws a shard not available failure-
Methods inherited from class org.elasticsearch.action.support.replication.TransportReplicationAction
doExecute, getIndexShard, newResponseInstance, registerRequestHandlers, resolveIndex, resolveRequest, retryPrimaryException, sendReplicaRequest, transportOptions
-
Methods inherited from class org.elasticsearch.action.support.TransportAction
execute, execute, execute
-
-
-
-
Constructor Detail
-
TransportWriteAction
protected TransportWriteAction(Settings settings, java.lang.String actionName, TransportService transportService, ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ShardStateAction shardStateAction, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, java.util.function.Supplier<Request> request, java.util.function.Supplier<ReplicaRequest> replicaRequest, java.lang.String executor)
-
-
Method Detail
-
syncOperationResultOrThrow
protected static Translog.Location syncOperationResultOrThrow(Engine.Result operationResult, Translog.Location currentLocation) throws java.lang.Exception
Syncs operation result to the translog or throws a shard not available failure- Throws:
java.lang.Exception
-
locationToSync
public static Translog.Location locationToSync(Translog.Location current, Translog.Location next)
-
newReplicasProxy
protected ReplicationOperation.Replicas newReplicasProxy(long primaryTerm)
- Overrides:
newReplicasProxy
in classTransportReplicationAction<Request extends ReplicatedWriteRequest<Request>,ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse>
-
shardOperationOnPrimary
protected abstract TransportWriteAction.WritePrimaryResult<ReplicaRequest,Response> shardOperationOnPrimary(Request request, IndexShard primary) throws java.lang.Exception
Called on the primary with a reference to the primary IndexShard to modify.- Specified by:
shardOperationOnPrimary
in classTransportReplicationAction<Request extends ReplicatedWriteRequest<Request>,ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse>
- Parameters:
request
- the request to the primary shardprimary
- the primary shard to perform the operation on- Returns:
- the result of the operation on primary, including current translog location and operation response and failure
async refresh is performed on the
primary
shard according to theRequest
refresh policy - Throws:
java.lang.Exception
-
shardOperationOnReplica
protected abstract TransportWriteAction.WriteReplicaResult<ReplicaRequest> shardOperationOnReplica(ReplicaRequest request, IndexShard replica) throws java.lang.Exception
Called once per replica with a reference to the replica IndexShard to modify.- Specified by:
shardOperationOnReplica
in classTransportReplicationAction<Request extends ReplicatedWriteRequest<Request>,ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse>
- Parameters:
request
- the request to the replica shardreplica
- the replica shard to perform the operation on- Returns:
- the result of the operation on replica, including current translog location and operation response and failure
async refresh is performed on the
replica
shard according to theReplicaRequest
refresh policy - Throws:
java.lang.Exception
-
globalBlockLevel
protected ClusterBlockLevel globalBlockLevel()
Description copied from class:TransportReplicationAction
Cluster level block to check before request execution. Returning null means that no blocks need to be checked.- Overrides:
globalBlockLevel
in classTransportReplicationAction<Request extends ReplicatedWriteRequest<Request>,ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse>
-
indexBlockLevel
protected ClusterBlockLevel indexBlockLevel()
Description copied from class:TransportReplicationAction
Index level block to check before request execution. Returning null means that no blocks need to be checked.- Overrides:
indexBlockLevel
in classTransportReplicationAction<Request extends ReplicatedWriteRequest<Request>,ReplicaRequest extends ReplicatedWriteRequest<ReplicaRequest>,Response extends ReplicationResponse & WriteResponse>
-
-