Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.action.support.replication;

import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
Expand Down Expand Up @@ -47,6 +48,8 @@
public abstract class ReplicationRequest<Request extends ReplicationRequest<Request>> extends ActionRequest
implements IndicesRequest {

private static final Version COMPACT_INDEX_NAME_VERSION = Version.V_8_0_0;

public static final TimeValue DEFAULT_TIMEOUT = new TimeValue(1, TimeUnit.MINUTES);

/**
Expand All @@ -68,14 +71,19 @@ public abstract class ReplicationRequest<Request extends ReplicationRequest<Requ

public ReplicationRequest(StreamInput in) throws IOException {
super(in);
if (in.readBoolean()) {
boolean hasShardId = in.readBoolean();
if (hasShardId) {
shardId = new ShardId(in);
} else {
shardId = null;
}
waitForActiveShards = ActiveShardCount.readFrom(in);
timeout = in.readTimeValue();
index = in.readString();
if (hasShardId && in.getVersion().onOrAfter(COMPACT_INDEX_NAME_VERSION)) {
index = shardId.getIndexName();
} else {
index = in.readString();
}
routedBasedOnClusterVersion = in.readVLong();
}

Expand Down Expand Up @@ -114,6 +122,7 @@ public String index() {

@SuppressWarnings("unchecked")
public final Request index(String index) {
assert shardId == null : "Tried setting index but already has set shard id [" + shardId + "]";
this.index = index;
return (Request) this;
}
Expand Down Expand Up @@ -193,7 +202,9 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(shardId);
waitForActiveShards.writeTo(out);
out.writeTimeValue(timeout);
out.writeString(index);
if (shardId == null || out.getVersion().before(COMPACT_INDEX_NAME_VERSION)) {
out.writeString(index);
}
out.writeVLong(routedBasedOnClusterVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public ClusterBlockLevel indexBlockLevel() {
assertIndexShardUninitialized();
}
{
Request requestWithTimeout = new Request(new ShardId("unknown", "_na_", 0)).index("unknown").timeout("5ms");
Request requestWithTimeout = new Request(new ShardId("unknown", "_na_", 0)).timeout("5ms");
PlainActionFuture<TestResponse> listener = new PlainActionFuture<>();
ReplicationTask task = maybeTask();

Expand Down