@@ -319,9 +319,11 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure)
319
319
long numDocsIndexed = Math .min (3000 * 2 , randomLongBetween (maxReadSize , maxReadSize * 10 ));
320
320
atLeastDocsIndexed ("index1" , numDocsIndexed / 3 );
321
321
322
- final FollowIndexAction .Request followRequest = new FollowIndexAction .Request ("index1" , "index2" , maxReadSize ,
323
- randomIntBetween (2 , 10 ), Long .MAX_VALUE , randomIntBetween (2 , 10 ),
324
- randomIntBetween (1024 , 10240 ), TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
322
+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
323
+ followRequest .setMaxBatchOperationCount (maxReadSize );
324
+ followRequest .setMaxConcurrentReadBatches (randomIntBetween (2 , 10 ));
325
+ followRequest .setMaxConcurrentWriteBatches (randomIntBetween (2 , 10 ));
326
+ followRequest .setMaxWriteBufferSize (randomIntBetween (1024 , 10240 ));
325
327
CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
326
328
client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
327
329
@@ -358,9 +360,10 @@ public void testFollowIndexAndCloseNode() throws Exception {
358
360
});
359
361
thread .start ();
360
362
361
- final FollowIndexAction .Request followRequest = new FollowIndexAction .Request ("index1" , "index2" , randomIntBetween (32 , 2048 ),
362
- randomIntBetween (2 , 10 ), Long .MAX_VALUE , randomIntBetween (2 , 10 ),
363
- FollowIndexAction .DEFAULT_MAX_WRITE_BUFFER_SIZE , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
363
+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
364
+ followRequest .setMaxBatchOperationCount (randomIntBetween (32 , 2048 ));
365
+ followRequest .setMaxConcurrentReadBatches (randomIntBetween (2 , 10 ));
366
+ followRequest .setMaxConcurrentWriteBatches (randomIntBetween (2 , 10 ));
364
367
client ().execute (CreateAndFollowIndexAction .INSTANCE , new CreateAndFollowIndexAction .Request (followRequest )).get ();
365
368
366
369
long maxNumDocsReplicated = Math .min (1000 , randomLongBetween (followRequest .getMaxBatchOperationCount (),
@@ -447,7 +450,7 @@ public void testFollowNonExistentIndex() throws Exception {
447
450
.actionGet ());
448
451
}
449
452
450
- public void testFollowIndex_lowMaxTranslogBytes () throws Exception {
453
+ public void testFollowIndexMaxOperationSizeInBytes () throws Exception {
451
454
final String leaderIndexSettings = getIndexSettings (1 , between (0 , 1 ),
452
455
singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
453
456
assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
@@ -460,8 +463,8 @@ public void testFollowIndex_lowMaxTranslogBytes() throws Exception {
460
463
client ().prepareIndex ("index1" , "doc" , Integer .toString (i )).setSource (source , XContentType .JSON ).get ();
461
464
}
462
465
463
- final FollowIndexAction .Request followRequest = new FollowIndexAction . Request ("index1" , "index2" , 1024 , 1 , 1024L ,
464
- 1 , 10240 , TimeValue . timeValueMillis ( 500 ), TimeValue . timeValueMillis ( 10 ) );
466
+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
467
+ followRequest . setMaxOperationSizeInBytes ( 1L );
465
468
final CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
466
469
client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
467
470
@@ -489,25 +492,21 @@ public void testDontFollowTheWrongIndex() throws Exception {
489
492
assertAcked (client ().admin ().indices ().prepareCreate ("index3" ).setSource (leaderIndexSettings , XContentType .JSON ));
490
493
ensureGreen ("index3" );
491
494
492
- FollowIndexAction .Request followRequest = new FollowIndexAction .Request ("index1" , "index2" , 1024 , 1 , 1024L ,
493
- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
495
+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
494
496
CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
495
497
client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
496
498
497
- followRequest = new FollowIndexAction .Request ("index3" , "index4" , 1024 , 1 , 1024L ,
498
- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
499
+ followRequest = createFollowRequest ("index3" , "index4" );
499
500
createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
500
501
client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
501
502
unfollowIndex ("index2" , "index4" );
502
503
503
- FollowIndexAction .Request wrongRequest1 = new FollowIndexAction .Request ("index1" , "index4" , 1024 , 1 , 1024L ,
504
- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
504
+ FollowIndexAction .Request wrongRequest1 = createFollowRequest ("index1" , "index4" );
505
505
Exception e = expectThrows (IllegalArgumentException .class ,
506
506
() -> client ().execute (FollowIndexAction .INSTANCE , wrongRequest1 ).actionGet ());
507
507
assertThat (e .getMessage (), containsString ("follow index [index4] should reference" ));
508
508
509
- FollowIndexAction .Request wrongRequest2 = new FollowIndexAction .Request ("index3" , "index2" , 1024 , 1 , 1024L ,
510
- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
509
+ FollowIndexAction .Request wrongRequest2 = createFollowRequest ("index3" , "index2" );
511
510
e = expectThrows (IllegalArgumentException .class , () -> client ().execute (FollowIndexAction .INSTANCE , wrongRequest2 ).actionGet ());
512
511
assertThat (e .getMessage (), containsString ("follow index [index2] should reference" ));
513
512
}
@@ -716,10 +715,12 @@ private void assertSameDocCount(String index1, String index2) throws Exception {
716
715
}, 60 , TimeUnit .SECONDS );
717
716
}
718
717
719
- public static FollowIndexAction .Request createFollowRequest (String leaderIndex , String followIndex ) {
720
- return new FollowIndexAction .Request (leaderIndex , followIndex , FollowIndexAction .DEFAULT_MAX_BATCH_OPERATION_COUNT ,
721
- FollowIndexAction .DEFAULT_MAX_CONCURRENT_READ_BATCHES , FollowIndexAction .DEFAULT_MAX_BATCH_SIZE_IN_BYTES ,
722
- FollowIndexAction .DEFAULT_MAX_CONCURRENT_WRITE_BATCHES , FollowIndexAction .DEFAULT_MAX_WRITE_BUFFER_SIZE ,
723
- TimeValue .timeValueMillis (10 ), TimeValue .timeValueMillis (10 ));
718
+ public static FollowIndexAction .Request createFollowRequest (String leaderIndex , String followerIndex ) {
719
+ FollowIndexAction .Request request = new FollowIndexAction .Request ();
720
+ request .setLeaderIndex (leaderIndex );
721
+ request .setFollowerIndex (followerIndex );
722
+ request .setMaxRetryDelay (TimeValue .timeValueMillis (10 ));
723
+ request .setPollTimeout (TimeValue .timeValueMillis (10 ));
724
+ return request ;
724
725
}
725
726
}
0 commit comments