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 likeIndexRequestorTransportShardRefreshAction.
-
-
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 TimeValueDEFAULT_TIMEOUTprotected java.lang.Stringindexprotected ShardIdshardIdTarget shard the request should execute on.protected TimeValuetimeoutprotected ActiveShardCountwaitForActiveShardsThe 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 TaskcreateTask(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.StringgetDescription()Returns optional description of the request to be displayed by the task managerjava.lang.Stringindex()Requestindex(java.lang.String index)java.lang.String[]indices()Returns the array of indices that the action relates toIndicesOptionsindicesOptions()Returns the indices options used to resolve indices.voidonRetry()This method is called before this replication request is retried the first time.voidreadFrom(StreamInput in)Set this object's fields from a StreamInput.RequestsetShardId(ShardId shardId)Sets the target shard id for the request.ShardIdshardId()TimeValuetimeout()Requesttimeout(java.lang.String timeout)A timeout to wait if the index operation can't be performed immediately.Requesttimeout(TimeValue timeout)A timeout to wait if the index operation can't be performed immediately.abstract java.lang.StringtoString()ActionRequestValidationExceptionvalidate()ActiveShardCountwaitForActiveShards()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.RequestwaitForActiveShards(ActiveShardCount waitForActiveShards)Sets the number of shard copies that must be active before proceeding with the replication operation.voidwriteTo(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:IndicesRequestReturns the array of indices that the action relates to- Specified by:
indicesin interfaceIndicesRequest
-
indicesOptions
public IndicesOptions 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
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.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
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:
validatein classActionRequest
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:StreamableSet this object's fields from a StreamInput.- Specified by:
readFromin interfaceStreamable- Overrides:
readFromin classActionRequest- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:StreamableWrite this object's fields to a StreamOutput.- Specified by:
writeToin interfaceStreamable- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin 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:TaskAwareRequestReturns the task object that should be used to keep track of the processing of the request. A request can override this method and return null to avoid being tracked by the task manager.- Specified by:
createTaskin 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:
toStringin classjava.lang.Object
-
getDescription
public java.lang.String 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.
-
-