Module org.elasticsearch.server
Class ReplicationRequest<Request extends ReplicationRequest<Request>>
java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.AbstractTransportRequest
org.elasticsearch.action.ActionRequest
org.elasticsearch.action.LegacyActionRequest
org.elasticsearch.action.support.replication.ReplicationRequest<Request>
- All Implemented Interfaces:
IndicesRequest,Writeable,RefCounted,TaskAwareRequest,TransportRequest
- Direct Known Subclasses:
BasicReplicationRequest,GlobalCheckpointSyncAction.Request,ReplicatedWriteRequest,RetentionLeaseBackgroundSyncAction.Request,ShardFlushRequest,ShardRefreshReplicaRequest,TransportVerifyShardBeforeCloseAction.ShardRequest,TransportVerifyShardIndexBlockAction.ShardRequest
public abstract class ReplicationRequest<Request extends ReplicationRequest<Request>>
extends LegacyActionRequest
implements IndicesRequest
Requests that are run on a particular replica, first on the primary and then on the replicas like
IndexRequest or
TransportShardRefreshAction.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.RemoteClusterShardRequest, IndicesRequest.Replaceable, IndicesRequest.SingleIndexNoWildcardsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TimeValueprotected Stringprotected final intThe reshardSplitShardCountSummary has been added to accommodate the Resharding feature.protected final ShardIdTarget shard the request should execute on.protected TimeValueprotected ActiveShardCountThe number of shard copies that must be active before proceeding with the replication action.Fields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED -
Constructor Summary
ConstructorsConstructorDescriptionReplicationRequest(ShardId shardId) Creates a new request with resolved shard idReplicationRequest(ShardId shardId, int reshardSplitShardCountSummary) Creates a new request with resolved shard id and reshardSplitShardCountSummaryReplicationRequest(ShardId shardId, int reshardSplitShardCountSummary, StreamInput in) ReplicationRequest(ShardId shardId, StreamInput in) -
Method Summary
Modifier and TypeMethodDescriptionReturns the task object that should be used to keep track of the processing of the request.Returns optional description of the request to be displayed by the task managerindex()final RequestString[]indices()Returns the array of indices that the action relates toReturns the indices options used to resolve indices.voidonRetry()This method is called before this replication request is retried the first time.intprotected RequestroutedBasedOnClusterVersion(long routedBasedOnClusterVersion) Sets the minimum version of the cluster state that is required on the next node before we redirect to another primary.shardId()timeout()final RequestA timeout to wait if the index operation can't be performed immediately.abstract StringtoString()validate()final RequestwaitForActiveShards(int waitForActiveShards) A shortcut forwaitForActiveShards(ActiveShardCount)where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)to get the ActiveShardCount.final RequestwaitForActiveShards(ActiveShardCount waitForActiveShards) Sets the number of shard copies that must be active before proceeding with the replication operation.voidwriteThin(StreamOutput out) voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResultMethods inherited from class org.elasticsearch.transport.AbstractTransportRequest
getParentTask, getRequestId, remoteAddress, remoteAddress, setParentTask, setRequestIdMethods inherited from class org.elasticsearch.transport.TransportMessage
decRef, hasReferences, incRef, tryIncRefMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.action.IndicesRequest
includeDataStreamsMethods inherited from interface org.elasticsearch.core.RefCounted
decRef, hasReferences, incRef, mustIncRef, tryIncRefMethods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
createTask, setParentTask
-
Field Details
-
DEFAULT_TIMEOUT
-
shardId
Target shard the request should execute on. In case of index and delete requests, shard id gets resolved by the transport action before performing request operation and at request creation time for shard-level bulk, refresh and flush requests. -
timeout
-
index
-
reshardSplitShardCountSummary
protected final int reshardSplitShardCountSummaryThe reshardSplitShardCountSummary has been added to accommodate the Resharding feature. This is populated when the coordinator is deciding which shards a request applies to. For example,BulkOperationsplits an incoming bulk request into shard levelBulkShardRequestbased on its cluster state view of the number of shards that are ready for indexing. The purpose of this metadata is to reconcile the cluster state visible at the coordinating node with that visible at the source shard node. (w.r.t resharding). When an index is being split, there is a point in time when the newly created shard (target shard) takes over its portion of the document space from the original shard (source shard). Although the handoff is atomic at the original (source shard) and new shards (target shard), there is a window of time between the coordinating node creating a shard request and the shard receiving and processing it. This field is used by the original shard (source shard) when it processes the request to detect whether the coordinator's view of the new shard's state when it created the request matches the shard's current state, or whether the request must be reprocessed taking into account the current shard states. Note that we are able to get away with a single number, instead of an array of target shard states, because we only allow splits in increments of 2x. Example 1: Suppose we are resharding an index from 2 -> 4 shards. While splitting a bulk request, the coordinator observes that target shards are not ready for indexing. So requests that are meant for shard 0 and 2 are bundled together, sent to shard 0 with “reshardSplitShardCountSummary” 2 in the request. Requests that are meant for shard 1 and 3 are bundled together, sent to shard 1 with “reshardSplitShardCountSummary” 2 in the request. Example 2: Suppose we are resharding an index from 4 -> 8 shards. While splitting a bulk request, the coordinator observes that source shard 0 has completed HANDOFF but source shards 1, 2, 3 have not completed handoff. So, the shard-bulk-request it sends to shard 0 and 4 has the "reshardSplitShardCountSummary" 8, while the shard-bulk-request it sends to shard 1,2,3 has the "reshardSplitShardCountSummary" 4. Note that in this case no shard-bulk-request is sent to shards 5, 6, 7 and the requests that were meant for these target shards are bundled together with and sent to their source shards. A value of 0 indicates an INVALID reshardSplitShardCountSummary. Hence, a request with INVALID reshardSplitShardCountSummary will be treated as a Summary mismatch on the source shard node. -
waitForActiveShards
The number of shard copies that must be active before proceeding with the replication action.
-
-
Constructor Details
-
ReplicationRequest
- Throws:
IOException
-
ReplicationRequest
- Throws:
IOException
-
ReplicationRequest
public ReplicationRequest(@Nullable ShardId shardId, int reshardSplitShardCountSummary, StreamInput in) throws IOException - Throws:
IOException
-
ReplicationRequest
Creates a new request with resolved shard id -
ReplicationRequest
Creates a new request with resolved shard id and reshardSplitShardCountSummary
-
-
Method Details
-
timeout
A timeout to wait if the index operation can't be performed immediately. Defaults to1m. -
timeout
-
index
-
index
-
indices
Description copied from interface:IndicesRequestReturns the array of indices that the action relates to- Specified by:
indicesin interfaceIndicesRequest
-
indicesOptions
Description copied from interface:IndicesRequestReturns the indices options used to resolve indices. They tell for instance whether a single index is accepted, whether an empty array will be converted to _all, and how wildcards will be expanded if needed.- Specified by:
indicesOptionsin interfaceIndicesRequest
-
waitForActiveShards
-
shardId
- Returns:
- the shardId of the shard where this operation should be executed on. can be null if the shardID has not yet been resolved
-
reshardSplitShardCountSummary
public int reshardSplitShardCountSummary()- Returns:
- The effective shard count as seen by the coordinator when creating this request. can be 0 if this has not yet been resolved.
-
waitForActiveShards
Sets the number of shard copies that must be active before proceeding with the replication operation. Defaults toActiveShardCount.DEFAULT, which requires one shard copy (the primary) to be active. Set this value toActiveShardCount.ALLto wait for all shards (primary and all replicas) to be active. Otherwise, useActiveShardCount.from(int)to set this value to any non-negative integer, up to the total number of shard copies (number of replicas + 1). -
waitForActiveShards
A shortcut forwaitForActiveShards(ActiveShardCount)where the numerical shard count is passed in, instead of having to first callActiveShardCount.from(int)to get the ActiveShardCount. -
routedBasedOnClusterVersion
Sets the minimum version of the cluster state that is required on the next node before we redirect to another primary. Used to prevent redirect loops, see alsoAbstractRunnable.doRun() -
validate
- Specified by:
validatein classActionRequest
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classActionRequest- Throws:
IOException
-
writeThin
Thin serialization that does not writeshardIdand will only writeindexif it is different from the index name inshardId. Since we do not writeshardId, we also do not writereshardSplitShardCountSummary.- Throws:
IOException
-
createTask
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) Description copied from interface:TaskAwareRequestReturns the task object that should be used to keep track of the processing of the request.- Specified by:
createTaskin interfaceTaskAwareRequest
-
toString
- Overrides:
toStringin classAbstractTransportRequest
-
getDescription
Description copied from interface:TaskAwareRequestReturns optional description of the request to be displayed by the task manager- Specified by:
getDescriptionin interfaceTaskAwareRequest
-
onRetry
public void onRetry()This method is called before this replication request is retried the first time.
-