[CCR] Made leader cluster required in shard follow task.

Left over from #34580
This commit is contained in:
Martijn van Groningen 2018-10-24 08:38:25 +02:00
parent abf8cb6706
commit 18007a29b2
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
2 changed files with 3 additions and 14 deletions

View File

@ -122,7 +122,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
} }
public ShardFollowTask(StreamInput in) throws IOException { public ShardFollowTask(StreamInput in) throws IOException {
this.leaderCluster = in.readOptionalString(); this.leaderCluster = in.readString();
this.followShardId = ShardId.readShardId(in); this.followShardId = ShardId.readShardId(in);
this.leaderShardId = ShardId.readShardId(in); this.leaderShardId = ShardId.readShardId(in);
this.maxBatchOperationCount = in.readVInt(); this.maxBatchOperationCount = in.readVInt();
@ -190,7 +190,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalString(leaderCluster); out.writeString(leaderCluster);
followShardId.writeTo(out); followShardId.writeTo(out);
leaderShardId.writeTo(out); leaderShardId.writeTo(out);
out.writeVLong(maxBatchOperationCount); out.writeVLong(maxBatchOperationCount);
@ -210,9 +210,7 @@ public class ShardFollowTask implements XPackPlugin.XPackPersistentTaskParams {
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(); builder.startObject();
if (leaderCluster != null) { builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
builder.field(LEADER_CLUSTER_FIELD.getPreferredName(), leaderCluster);
}
builder.field(FOLLOW_SHARD_INDEX_FIELD.getPreferredName(), followShardId.getIndex().getName()); builder.field(FOLLOW_SHARD_INDEX_FIELD.getPreferredName(), followShardId.getIndex().getName());
builder.field(FOLLOW_SHARD_INDEX_UUID_FIELD.getPreferredName(), followShardId.getIndex().getUUID()); builder.field(FOLLOW_SHARD_INDEX_UUID_FIELD.getPreferredName(), followShardId.getIndex().getUUID());
builder.field(FOLLOW_SHARD_SHARDID_FIELD.getPreferredName(), followShardId.id()); builder.field(FOLLOW_SHARD_SHARDID_FIELD.getPreferredName(), followShardId.id());

View File

@ -67,15 +67,6 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor<ShardFollo
@Override @Override
public void validate(ShardFollowTask params, ClusterState clusterState) { public void validate(ShardFollowTask params, ClusterState clusterState) {
if (params.getLeaderCluster() == null) {
// We can only validate IndexRoutingTable in local cluster,
// for remote cluster we would need to make a remote call and we cannot do this here.
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(params.getLeaderShardId().getIndex());
if (routingTable.shard(params.getLeaderShardId().id()).primaryShard().started() == false) {
throw new IllegalArgumentException("Not all copies of leader shard are started");
}
}
IndexRoutingTable routingTable = clusterState.getRoutingTable().index(params.getFollowShardId().getIndex()); IndexRoutingTable routingTable = clusterState.getRoutingTable().index(params.getFollowShardId().getIndex());
if (routingTable.shard(params.getFollowShardId().id()).primaryShard().started() == false) { if (routingTable.shard(params.getFollowShardId().id()).primaryShard().started() == false) {
throw new IllegalArgumentException("Not all copies of follow shard are started"); throw new IllegalArgumentException("Not all copies of follow shard are started");