Class ReplicationRequest<Request extends ReplicationRequest<Request>>

All Implemented Interfaces:
IndicesRequest, Writeable, org.elasticsearch.core.RefCounted, TaskAwareRequest
Direct Known Subclasses:
BasicReplicationRequest, GlobalCheckpointSyncAction.Request, ReplicatedWriteRequest, RetentionLeaseBackgroundSyncAction.Request, ShardFlushRequest, TransportVerifyShardBeforeCloseAction.ShardRequest, TransportVerifyShardIndexBlockAction.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.
  • Field Details

    • DEFAULT_TIMEOUT

      public static final org.elasticsearch.core.TimeValue DEFAULT_TIMEOUT
    • shardId

      protected final 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 org.elasticsearch.core.TimeValue timeout
    • index

      protected String index
    • waitForActiveShards

      protected ActiveShardCount waitForActiveShards
      The number of shard copies that must be active before proceeding with the replication action.
  • Constructor Details

  • Method Details

    • timeout

      public final Request timeout(org.elasticsearch.core.TimeValue timeout)
      A timeout to wait if the index operation can't be performed immediately. Defaults to 1m.
    • timeout

      public final Request timeout(String timeout)
      A timeout to wait if the index operation can't be performed immediately. Defaults to 1m.
    • timeout

      public org.elasticsearch.core.TimeValue timeout()
    • index

      public String index()
    • index

      public final Request index(String index)
    • indices

      public String[] indices()
      Description copied from interface: IndicesRequest
      Returns the array of indices that the action relates to
      Specified by:
      indices in interface IndicesRequest
    • 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 interface IndicesRequest
    • 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 to ActiveShardCount.DEFAULT, which requires one shard copy (the primary) to be active. Set this value to ActiveShardCount.ALL to wait for all shards (primary and all replicas) to be active. Otherwise, use ActiveShardCount.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 for waitForActiveShards(ActiveShardCount) where the numerical shard count is passed in, instead of having to first call ActiveShardCount.from(int) to get the ActiveShardCount.
    • routedBasedOnClusterVersion

      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. Used to prevent redirect loops, see also AbstractRunnable.doRun()
    • validate

      Specified by:
      validate in class ActionRequest
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Overrides:
      writeTo in class ActionRequest
      Throws:
      IOException
    • writeThin

      public void writeThin(StreamOutput out) throws IOException
      Thin serialization that does not write shardId and will only write index if it is different from the index name in shardId.
      Throws:
      IOException
    • createTask

      public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String,​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 interface TaskAwareRequest
    • toString

      public abstract String toString()
      Overrides:
      toString in class TransportRequest
    • getDescription

      public String getDescription()
      Description copied from interface: TaskAwareRequest
      Returns optional description of the request to be displayed by the task manager
      Specified by:
      getDescription in interface TaskAwareRequest
    • onRetry

      public void onRetry()
      This method is called before this replication request is retried the first time.