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
,Streamable
,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 likeIndexRequest
orTransportShardRefreshAction
.
-
-
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()
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.void
readFrom(StreamInput in)
Set this object's fields from a StreamInput.Request
setShardId(ShardId shardId)
Sets the target shard id for the request.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 object's fields to a StreamOutput.-
Methods inherited from class org.elasticsearch.action.ActionRequest
getShouldStoreResult
-
Methods inherited from class org.elasticsearch.transport.TransportRequest
getParentTask, setParentTask
-
Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.tasks.TaskAwareRequest
setParentTask
-
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final TimeValue DEFAULT_TIMEOUT
-
shardId
protected ShardId 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
protected TimeValue timeout
-
index
protected java.lang.String index
-
waitForActiveShards
protected ActiveShardCount waitForActiveShards
The number of shard copies that must be active before proceeding with the replication action.
-
-
Constructor Detail
-
ReplicationRequest
public ReplicationRequest()
-
ReplicationRequest
public ReplicationRequest(ShardId shardId)
Creates a new request with resolved shard id
-
-
Method Detail
-
timeout
public final Request timeout(TimeValue timeout)
A timeout to wait if the index operation can't be performed immediately. Defaults to1m
.
-
timeout
public final Request timeout(java.lang.String timeout)
A timeout to wait if the index operation can't be performed immediately. Defaults to1m
.
-
timeout
public TimeValue timeout()
-
index
public java.lang.String index()
-
index
public final Request index(java.lang.String 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
public IndicesOptions 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
public ActiveShardCount waitForActiveShards()
-
shardId
@Nullable public ShardId 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
public final Request waitForActiveShards(ActiveShardCount 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
public final 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.
-
validate
public ActionRequestValidationException validate()
- Specified by:
validate
in classActionRequest
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:Streamable
Set this object's fields from a StreamInput.- Specified by:
readFrom
in interfaceStreamable
- Overrides:
readFrom
in classActionRequest
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Streamable
Write this object's fields to a StreamOutput.- Specified by:
writeTo
in interfaceStreamable
- 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
-
setShardId
public Request setShardId(ShardId shardId)
Sets the target shard id for the request. The shard id is set when a index/delete request is resolved by the transport action
-
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.
-
-