Class ReplicationRequest<Request extends ReplicationRequest<Request>>
java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportRequest
org.elasticsearch.action.ActionRequest
org.elasticsearch.action.support.replication.ReplicationRequest<Request>
- All Implemented Interfaces:
IndicesRequest
,Writeable
,TaskAwareRequest
- Direct Known Subclasses:
BasicReplicationRequest
,GlobalCheckpointSyncAction.Request
,ReplicatedWriteRequest
,RetentionLeaseBackgroundSyncAction.Request
,ShardFlushRequest
,TransportVerifyShardBeforeCloseAction.ShardRequest
public abstract class ReplicationRequest<Request extends ReplicationRequest<Request>> extends ActionRequest 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 class org.elasticsearch.transport.TransportRequest
TransportRequest.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.action.IndicesRequest
IndicesRequest.Replaceable
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields Modifier and Type Field Description static TimeValue
DEFAULT_TIMEOUT
protected java.lang.String
index
protected ShardId
shardId
Target shard the request should execute on.protected TimeValue
timeout
protected ActiveShardCount
waitForActiveShards
The number of shard copies that must be active before proceeding with the replication action. -
Constructor Summary
Constructors Constructor Description ReplicationRequest(StreamInput in)
ReplicationRequest(ShardId shardId)
Creates a new request with resolved shard id -
Method Summary
Modifier and Type Method Description Task
createTask(long id, java.lang.String type, java.lang.String action, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers)
Returns the task object that should be used to keep track of the processing of the request.java.lang.String
getDescription()
Returns optional description of the request to be displayed by the task managerjava.lang.String
index()
Request
index(java.lang.String index)
java.lang.String[]
indices()
Returns the array of indices that the action relates toIndicesOptions
indicesOptions()
Returns the indices options used to resolve indices.void
onRetry()
This method is called before this replication request is retried the first time.protected Request
routedBasedOnClusterVersion(long routedBasedOnClusterVersion)
Sets the minimum version of the cluster state that is required on the next node before we redirect to another primary.ShardId
shardId()
TimeValue
timeout()
Request
timeout(java.lang.String timeout)
A timeout to wait if the index operation can't be performed immediately.Request
timeout(TimeValue timeout)
A timeout to wait if the index operation can't be performed immediately.abstract java.lang.String
toString()
ActionRequestValidationException
validate()
ActiveShardCount
waitForActiveShards()
Request
waitForActiveShards(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.Request
waitForActiveShards(ActiveShardCount waitForActiveShards)
Sets the number of shard copies that must be active before proceeding with the replication operation.void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask
Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
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
protected java.lang.String index -
waitForActiveShards
The number of shard copies that must be active before proceeding with the replication action.
-
-
Constructor Details
-
ReplicationRequest
- Throws:
java.io.IOException
-
ReplicationRequest
Creates a new request with resolved shard id
-
-
Method Details
-
timeout
A timeout to wait if the index operation can't be performed immediately. Defaults to1m
. -
timeout
A timeout to wait if the index operation can't be performed immediately. Defaults to1m
. -
timeout
-
index
public java.lang.String index() -
index
-
indices
public java.lang.String[] indices()Description copied from interface:IndicesRequest
Returns the array of indices that the action relates to- Specified by:
indices
in interfaceIndicesRequest
-
indicesOptions
Description copied from interface:IndicesRequest
Returns 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:
indicesOptions
in 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
-
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.ALL
to 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:
validate
in classActionRequest
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classActionRequest
- Throws:
java.io.IOException
-
createTask
public Task createTask(long id, java.lang.String type, java.lang.String action, TaskId parentTaskId, java.util.Map<java.lang.String,java.lang.String> headers)Description copied from interface:TaskAwareRequest
Returns the task object that should be used to keep track of the processing of the request.- Specified by:
createTask
in interfaceTaskAwareRequest
-
toString
public abstract java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
getDescription
public java.lang.String getDescription()Description copied from interface:TaskAwareRequest
Returns optional description of the request to be displayed by the task manager- Specified by:
getDescription
in interfaceTaskAwareRequest
-
onRetry
public void onRetry()This method is called before this replication request is retried the first time.
-