Skip to content

Commit 03b67b3

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 176013e commit 03b67b3

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
@@ -254,7 +254,7 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
254254
return Arrays.asList(
255255
// Persistent action requests
256256
new NamedWriteableRegistry.Entry(PersistentTaskParams.class, ShardFollowTask.NAME,
257-
ShardFollowTask::new),
257+
ShardFollowTask::readFrom),
258258

259259
// Task statuses
260260
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
@@ -526,7 +526,7 @@ private void followLeaderIndex(String autoFollowPattenName,
526526
request.getParameters().setMaxWriteBufferCount(pattern.getMaxWriteBufferCount());
527527
request.getParameters().setMaxWriteBufferSize(pattern.getMaxWriteBufferSize());
528528
request.getParameters().setMaxRetryDelay(pattern.getMaxRetryDelay());
529-
request.getParameters().setReadPollTimeout(pattern.getPollTimeout());
529+
request.getParameters().setReadPollTimeout(pattern.getReadPollTimeout());
530530

531531
// Execute if the create and follow api call succeeds:
532532
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
@@ -159,11 +159,11 @@ static ClusterState innerPut(PutAutoFollowPatternAction.Request request,
159159
request.getLeaderIndexPatterns(),
160160
request.getFollowIndexNamePattern(),
161161
request.getParameters().getMaxReadRequestOperationCount(),
162-
request.getParameters().getMaxReadRequestSize(),
163-
request.getParameters().getMaxOutstandingReadRequests(),
164162
request.getParameters().getMaxWriteRequestOperationCount(),
165-
request.getParameters().getMaxWriteRequestSize(),
163+
request.getParameters().getMaxOutstandingReadRequests(),
166164
request.getParameters().getMaxOutstandingWriteRequests(),
165+
request.getParameters().getMaxReadRequestSize(),
166+
request.getParameters().getMaxWriteRequestSize(),
167167
request.getParameters().getMaxWriteBufferCount(),
168168
request.getParameters().getMaxWriteBufferSize(),
169169
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
@@ -324,11 +324,11 @@ private static ShardFollowTask createShardFollowTask(
324324
new ShardId(followIndexMetadata.getIndex(), shardId),
325325
new ShardId(leaderIndexMetadata.getIndex(), shardId),
326326
maxReadRequestOperationCount,
327-
maxReadRequestSize,
328-
maxOutstandingReadRequests,
329327
maxWriteRequestOperationCount,
330-
maxWriteRequestSize,
328+
maxOutstandingReadRequests,
331329
maxOutstandingWriteRequests,
330+
maxReadRequestSize,
331+
maxWriteRequestSize,
332332
maxWriteBufferCount,
333333
maxWriteBufferSize,
334334
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
@@ -367,11 +367,11 @@ private ShardFollowNodeTask createShardFollowTask(ReplicationGroup leaderGroup,
367367
new ShardId("follow_index", "", 0),
368368
new ShardId("leader_index", "", 0),
369369
between(1, 64),
370-
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
371-
between(1, 8),
372370
between(1, 64),
373-
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
371+
between(1, 8),
374372
between(1, 4),
373+
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
374+
new ByteSizeValue(Long.MAX_VALUE, ByteSizeUnit.BYTES),
375375
10240,
376376
new ByteSizeValue(512, ByteSizeUnit.MB),
377377
TimeValue.timeValueMillis(10),

0 commit comments

Comments
 (0)