Skip to content

Commit f3fd81c

Browse files
committed
Introduced class reuses follow parameter code between ShardFollowTasks (#38910)
and AutoFollowPattern classes. The ImmutableFollowParameters is like the already existing FollowParameters, but all of its fields are final.
1 parent d32a31e commit f3fd81c

16 files changed

+317
-382
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
261261
return Arrays.asList(
262262
// Persistent action requests
263263
new NamedWriteableRegistry.Entry(PersistentTaskParams.class, ShardFollowTask.NAME,
264-
ShardFollowTask::new),
264+
ShardFollowTask::readFrom),
265265

266266
// Task statuses
267267
new NamedWriteableRegistry.Entry(Task.Status.class, ShardFollowNodeTaskStatus.STATUS_PARSER_NAME,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ private void followLeaderIndex(String autoFollowPattenName,
523523
request.getParameters().setMaxWriteBufferCount(pattern.getMaxWriteBufferCount());
524524
request.getParameters().setMaxWriteBufferSize(pattern.getMaxWriteBufferSize());
525525
request.getParameters().setMaxRetryDelay(pattern.getMaxRetryDelay());
526-
request.getParameters().setReadPollTimeout(pattern.getPollTimeout());
526+
request.getParameters().setReadPollTimeout(pattern.getReadPollTimeout());
527527

528528
// Execute if the create and follow api call succeeds:
529529
Runnable successHandler = () -> {

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

Lines changed: 43 additions & 163 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ static ClusterState innerPut(PutAutoFollowPatternAction.Request request,
161161
request.getLeaderIndexPatterns(),
162162
request.getFollowIndexNamePattern(),
163163
request.getParameters().getMaxReadRequestOperationCount(),
164-
request.getParameters().getMaxReadRequestSize(),
165-
request.getParameters().getMaxOutstandingReadRequests(),
166164
request.getParameters().getMaxWriteRequestOperationCount(),
167-
request.getParameters().getMaxWriteRequestSize(),
165+
request.getParameters().getMaxOutstandingReadRequests(),
168166
request.getParameters().getMaxOutstandingWriteRequests(),
167+
request.getParameters().getMaxReadRequestSize(),
168+
request.getParameters().getMaxWriteRequestSize(),
169169
request.getParameters().getMaxWriteBufferCount(),
170170
request.getParameters().getMaxWriteBufferSize(),
171171
request.getParameters().getMaxRetryDelay(),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ private static ShardFollowTask createShardFollowTask(
323323
new ShardId(followIndexMetadata.getIndex(), shardId),
324324
new ShardId(leaderIndexMetadata.getIndex(), shardId),
325325
maxReadRequestOperationCount,
326-
maxReadRequestSize,
327-
maxOutstandingReadRequests,
328326
maxWriteRequestOperationCount,
329-
maxWriteRequestSize,
327+
maxOutstandingReadRequests,
330328
maxOutstandingWriteRequests,
329+
maxReadRequestSize,
330+
maxWriteRequestSize,
331331
maxWriteBufferCount,
332332
maxWriteBufferSize,
333333
maxRetryDelay,

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/AutoFollowMetadataTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ protected AutoFollowMetadata createTestInstance() {
4545
leaderPatterns,
4646
randomAlphaOfLength(4),
4747
randomIntBetween(0, Integer.MAX_VALUE),
48-
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
4948
randomIntBetween(0, Integer.MAX_VALUE),
5049
randomIntBetween(0, Integer.MAX_VALUE),
51-
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
5250
randomIntBetween(0, Integer.MAX_VALUE),
51+
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
52+
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
5353
randomIntBetween(0, Integer.MAX_VALUE),
5454
new ByteSizeValue(randomNonNegativeLong()),
5555
TimeValue.timeValueMillis(500),

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/GetAutoFollowPatternResponseTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ protected GetAutoFollowPatternAction.Response createTestInstance() {
3434
Collections.singletonList(randomAlphaOfLength(4)),
3535
randomAlphaOfLength(4),
3636
randomIntBetween(0, Integer.MAX_VALUE),
37-
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
3837
randomIntBetween(0, Integer.MAX_VALUE),
3938
randomIntBetween(0, Integer.MAX_VALUE),
40-
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
4139
randomIntBetween(0, Integer.MAX_VALUE),
40+
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
41+
new ByteSizeValue(randomNonNegativeLong(), ByteSizeUnit.BYTES),
4242
randomIntBetween(0, Integer.MAX_VALUE),
4343
new ByteSizeValue(randomNonNegativeLong()),
4444
TimeValue.timeValueMillis(500),

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTaskRandomTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ private ShardFollowNodeTask createShardFollowTask(int concurrency, TestRun testR
8282
new ShardId("follow_index", "", 0),
8383
new ShardId("leader_index", "", 0),
8484
testRun.maxOperationCount,
85-
TransportResumeFollowAction.DEFAULT_MAX_READ_REQUEST_SIZE,
86-
concurrency,
8785
testRun.maxOperationCount,
88-
TransportResumeFollowAction.DEFAULT_MAX_READ_REQUEST_SIZE,
8986
concurrency,
87+
concurrency,
88+
TransportResumeFollowAction.DEFAULT_MAX_READ_REQUEST_SIZE,
89+
TransportResumeFollowAction.DEFAULT_MAX_READ_REQUEST_SIZE,
9090
10240,
9191
new ByteSizeValue(512, ByteSizeUnit.MB),
9292
TimeValue.timeValueMillis(10),

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTaskTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,11 +960,11 @@ private ShardFollowNodeTask createShardFollowTask(ShardFollowTaskParams params)
960960
params.followShardId,
961961
params.leaderShardId,
962962
params.maxReadRequestOperationCount,
963-
params.maxReadRequestSize,
964-
params.maxOutstandingReadRequests,
965963
params.maxWriteRequestOperationCount,
966-
params.maxWriteRequestSize,
964+
params.maxOutstandingReadRequests,
967965
params.maxOutstandingWriteRequests,
966+
params.maxReadRequestSize,
967+
params.maxWriteRequestSize,
968968
params.maxWriteBufferCount,
969969
params.maxWriteBufferSize,
970970
params.maxRetryDelay,

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ private ShardFollowNodeTask createShardFollowTask(ReplicationGroup leaderGroup,
369369
new ShardId("follow_index", "", 0),
370370
new ShardId("leader_index", "", 0),
371371
between(1, 64),
372-
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
373-
between(1, 8),
374372
between(1, 64),
375-
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
373+
between(1, 8),
376374
between(1, 4),
375+
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
376+
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
377377
10240,
378378
new ByteSizeValue(512, ByteSizeUnit.MB),
379379
TimeValue.timeValueMillis(10),

0 commit comments

Comments
 (0)