Skip to content

Commit a50a55d

Browse files
martijnvgweizijun
authored andcommitted
Change ShardFollowTask to reuse common serialization logic (elastic#39094)
Initially in elastic#38910, ShardFollowTask was reusing ImmutableFollowParameters' serialization logic. After merging, bwc tests failed sometimes and the binary serialization that ShardFollowTask was originally was using was added back. ImmutableFollowParameters is using optional fields (optional vint) while ShardFollowTask was not (vint).
1 parent 62fe2af commit a50a55d

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ task verifyVersions {
160160
* after the backport of the backcompat code is complete.
161161
*/
162162

163-
boolean bwc_tests_enabled = false
164-
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/39094" /* place a PR link here when committing bwc changes */
165-
163+
boolean bwc_tests_enabled = true
164+
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
166165
if (bwc_tests_enabled == false) {
167166
if (bwc_tests_disabled_issue.isEmpty()) {
168167
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

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

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,15 @@ public static ShardFollowTask readFrom(StreamInput in) throws IOException {
9696
String remoteCluster = in.readString();
9797
ShardId followShardId = ShardId.readShardId(in);
9898
ShardId leaderShardId = ShardId.readShardId(in);
99-
// TODO: use ImmutableFollowParameters(StreamInput) constructor
100-
int maxReadRequestOperationCount = in.readVInt();
101-
ByteSizeValue maxReadRequestSize = new ByteSizeValue(in);
102-
int maxOutstandingReadRequests = in.readVInt();
103-
int maxWriteRequestOperationCount = in.readVInt();
104-
ByteSizeValue maxWriteRequestSize = new ByteSizeValue(in);
105-
int maxOutstandingWriteRequests = in.readVInt();
106-
int maxWriteBufferCount = in.readVInt();
107-
ByteSizeValue maxWriteBufferSize = new ByteSizeValue(in);
108-
TimeValue maxRetryDelay = in.readTimeValue();
109-
TimeValue readPollTimeout = in.readTimeValue();
110-
Map<String, String> headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
111-
return new ShardFollowTask(remoteCluster, followShardId, leaderShardId, maxReadRequestOperationCount,
112-
maxWriteRequestOperationCount, maxOutstandingReadRequests, maxOutstandingWriteRequests, maxReadRequestSize,
113-
maxWriteRequestSize, maxWriteBufferCount, maxWriteBufferSize, maxRetryDelay, readPollTimeout, headers);
99+
return new ShardFollowTask(remoteCluster, followShardId, leaderShardId, in);
100+
}
101+
102+
private ShardFollowTask(String remoteCluster, ShardId followShardId, ShardId leaderShardId, StreamInput in) throws IOException {
103+
super(in);
104+
this.remoteCluster = remoteCluster;
105+
this.followShardId = followShardId;
106+
this.leaderShardId = leaderShardId;
107+
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
114108
}
115109

116110
public String getRemoteCluster() {
@@ -139,17 +133,7 @@ public void writeTo(StreamOutput out) throws IOException {
139133
out.writeString(remoteCluster);
140134
followShardId.writeTo(out);
141135
leaderShardId.writeTo(out);
142-
// TODO: use super.writeTo()
143-
out.writeVLong(getMaxReadRequestOperationCount());
144-
getMaxReadRequestSize().writeTo(out);
145-
out.writeVInt(getMaxOutstandingReadRequests());
146-
out.writeVLong(getMaxWriteRequestOperationCount());
147-
getMaxWriteRequestSize().writeTo(out);
148-
out.writeVInt(getMaxOutstandingWriteRequests());
149-
out.writeVInt(getMaxWriteBufferCount());
150-
getMaxWriteBufferSize().writeTo(out);
151-
out.writeTimeValue(getMaxRetryDelay());
152-
out.writeTimeValue(getReadPollTimeout());
136+
super.writeTo(out);
153137
out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString);
154138
}
155139

0 commit comments

Comments
 (0)