Skip to content

Commit 18007a2

Browse files
committed
[CCR] Made leader cluster required in shard follow task.
Left over from #34580
1 parent abf8cb6 commit 18007a2

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTask.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
122122
}
123123

124124
public ShardFollowTask(StreamInput in) throws IOException {
125-
this.leaderCluster = in.readOptionalString();
125+
this.leaderCluster = in.readString();
126126
this.followShardId = ShardId.readShardId(in);
127127
this.leaderShardId = ShardId.readShardId(in);
128128
this.maxBatchOperationCount = in.readVInt();
@@ -190,7 +190,7 @@ public String getWriteableName() {
190190

191191
@Override
192192
public void writeTo(StreamOutput out) throws IOException {
193-
out.writeOptionalString(leaderCluster);
193+
out.writeString(leaderCluster);
194194
followShardId.writeTo(out);
195195
leaderShardId.writeTo(out);
196196
out.writeVLong(maxBatchOperationCount);
@@ -210,9 +210,7 @@ public static ShardFollowTask fromXContent(XContentParser parser) {
210210
@Override
211211
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
212212
builder.startObject();
213-
if (leaderCluster != null) {
214-
builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
215-
}
213+
builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
216214
builder.field(FOLLOW_SHARD_INDEX_FIELD.getPreferredName(), followShardId.getIndex().getName());
217215
builder.field(FOLLOW_SHARD_INDEX_UUID_FIELD.getPreferredName(), followShardId.getIndex().getUUID());
218216
builder.field(FOLLOW_SHARD_SHARDID_FIELD.getPreferredName(), followShardId.id());

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ public ShardFollowTasksExecutor(Settings settings, Client client, ThreadPool thr
6767

6868
@Override
6969
public void validate(ShardFollowTask params, ClusterState clusterState) {
70-
if (params.getLeaderCluster() == null) {
71-
// We can only validate IndexRoutingTable in local cluster,
72-
// for remote cluster we would need to make a remote call and we cannot do this here.
73-
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(params.getLeaderShardId().getIndex());
74-
if (routingTable.shard(params.getLeaderShardId().id()).primaryShard().started() == false) {
75-
throw new IllegalArgumentException("Not all copies of leader shard are started");
76-
}
77-
}
78-
7970
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(params.getFollowShardId().getIndex());
8071
if (routingTable.shard(params.getFollowShardId().id()).primaryShard().started() == false) {
8172
throw new IllegalArgumentException("Not all copies of follow shard are started");

0 commit comments

Comments
 (0)