@@ -318,9 +318,11 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure)
318318 long numDocsIndexed = Math .min (3000 * 2 , randomLongBetween (maxReadSize , maxReadSize * 10 ));
319319 atLeastDocsIndexed ("index1" , numDocsIndexed / 3 );
320320
321- final FollowIndexAction .Request followRequest = new FollowIndexAction .Request ("index1" , "index2" , maxReadSize ,
322- randomIntBetween (2 , 10 ), Long .MAX_VALUE , randomIntBetween (2 , 10 ),
323- randomIntBetween (1024 , 10240 ), TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
321+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
322+ followRequest .setMaxBatchOperationCount (maxReadSize );
323+ followRequest .setMaxConcurrentReadBatches (randomIntBetween (2 , 10 ));
324+ followRequest .setMaxConcurrentWriteBatches (randomIntBetween (2 , 10 ));
325+ followRequest .setMaxWriteBufferSize (randomIntBetween (1024 , 10240 ));
324326 CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
325327 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
326328
@@ -357,9 +359,10 @@ public void testFollowIndexAndCloseNode() throws Exception {
357359 });
358360 thread .start ();
359361
360- final FollowIndexAction .Request followRequest = new FollowIndexAction .Request ("index1" , "index2" , randomIntBetween (32 , 2048 ),
361- randomIntBetween (2 , 10 ), Long .MAX_VALUE , randomIntBetween (2 , 10 ),
362- FollowIndexAction .DEFAULT_MAX_WRITE_BUFFER_SIZE , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
362+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
363+ followRequest .setMaxBatchOperationCount (randomIntBetween (32 , 2048 ));
364+ followRequest .setMaxConcurrentReadBatches (randomIntBetween (2 , 10 ));
365+ followRequest .setMaxConcurrentWriteBatches (randomIntBetween (2 , 10 ));
363366 client ().execute (CreateAndFollowIndexAction .INSTANCE , new CreateAndFollowIndexAction .Request (followRequest )).get ();
364367
365368 long maxNumDocsReplicated = Math .min (1000 , randomLongBetween (followRequest .getMaxBatchOperationCount (),
@@ -446,7 +449,7 @@ public void testFollowNonExistentIndex() throws Exception {
446449 .actionGet ());
447450 }
448451
449- public void testFollowIndex_lowMaxTranslogBytes () throws Exception {
452+ public void testFollowIndexMaxOperationSizeInBytes () throws Exception {
450453 final String leaderIndexSettings = getIndexSettings (1 , between (0 , 1 ),
451454 singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
452455 assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
@@ -459,8 +462,8 @@ public void testFollowIndex_lowMaxTranslogBytes() throws Exception {
459462 client ().prepareIndex ("index1" , "doc" , Integer .toString (i )).setSource (source , XContentType .JSON ).get ();
460463 }
461464
462- final FollowIndexAction .Request followRequest = new FollowIndexAction . Request ("index1" , "index2" , 1024 , 1 , 1024L ,
463- 1 , 10240 , TimeValue . timeValueMillis ( 500 ), TimeValue . timeValueMillis ( 10 ) );
465+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
466+ followRequest . setMaxOperationSizeInBytes ( 1L );
464467 final CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
465468 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
466469
@@ -488,25 +491,21 @@ public void testDontFollowTheWrongIndex() throws Exception {
488491 assertAcked (client ().admin ().indices ().prepareCreate ("index3" ).setSource (leaderIndexSettings , XContentType .JSON ));
489492 ensureGreen ("index3" );
490493
491- FollowIndexAction .Request followRequest = new FollowIndexAction .Request ("index1" , "index2" , 1024 , 1 , 1024L ,
492- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
494+ FollowIndexAction .Request followRequest = createFollowRequest ("index1" , "index2" );
493495 CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
494496 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
495497
496- followRequest = new FollowIndexAction .Request ("index3" , "index4" , 1024 , 1 , 1024L ,
497- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
498+ followRequest = createFollowRequest ("index3" , "index4" );
498499 createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
499500 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
500501 unfollowIndex ("index2" , "index4" );
501502
502- FollowIndexAction .Request wrongRequest1 = new FollowIndexAction .Request ("index1" , "index4" , 1024 , 1 , 1024L ,
503- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
503+ FollowIndexAction .Request wrongRequest1 = createFollowRequest ("index1" , "index4" );
504504 Exception e = expectThrows (IllegalArgumentException .class ,
505505 () -> client ().execute (FollowIndexAction .INSTANCE , wrongRequest1 ).actionGet ());
506506 assertThat (e .getMessage (), containsString ("follow index [index4] should reference" ));
507507
508- FollowIndexAction .Request wrongRequest2 = new FollowIndexAction .Request ("index3" , "index2" , 1024 , 1 , 1024L ,
509- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
508+ FollowIndexAction .Request wrongRequest2 = createFollowRequest ("index3" , "index2" );
510509 e = expectThrows (IllegalArgumentException .class , () -> client ().execute (FollowIndexAction .INSTANCE , wrongRequest2 ).actionGet ());
511510 assertThat (e .getMessage (), containsString ("follow index [index2] should reference" ));
512511 }
@@ -715,10 +714,12 @@ private void assertSameDocCount(String index1, String index2) throws Exception {
715714 }, 60 , TimeUnit .SECONDS );
716715 }
717716
718- public static FollowIndexAction .Request createFollowRequest (String leaderIndex , String followIndex ) {
719- return new FollowIndexAction .Request (leaderIndex , followIndex , FollowIndexAction .DEFAULT_MAX_BATCH_OPERATION_COUNT ,
720- FollowIndexAction .DEFAULT_MAX_CONCURRENT_READ_BATCHES , FollowIndexAction .DEFAULT_MAX_BATCH_SIZE_IN_BYTES ,
721- FollowIndexAction .DEFAULT_MAX_CONCURRENT_WRITE_BATCHES , FollowIndexAction .DEFAULT_MAX_WRITE_BUFFER_SIZE ,
722- TimeValue .timeValueMillis (10 ), TimeValue .timeValueMillis (10 ));
717+ public static FollowIndexAction .Request createFollowRequest (String leaderIndex , String followerIndex ) {
718+ FollowIndexAction .Request request = new FollowIndexAction .Request ();
719+ request .setLeaderIndex (leaderIndex );
720+ request .setFollowerIndex (followerIndex );
721+ request .setMaxRetryDelay (TimeValue .timeValueMillis (10 ));
722+ request .setPollTimeout (TimeValue .timeValueMillis (10 ));
723+ return request ;
723724 }
724725}
0 commit comments