@@ -319,9 +319,11 @@ public void afterBulk(long executionId, BulkRequest request, Throwable failure)
319319 long numDocsIndexed = Math .min (3000 * 2 , randomLongBetween (maxReadSize , maxReadSize * 10 ));
320320 atLeastDocsIndexed ("index1" , numDocsIndexed / 3 );
321321
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 ));
325327 CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
326328 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
327329
@@ -358,9 +360,10 @@ public void testFollowIndexAndCloseNode() throws Exception {
358360 });
359361 thread .start ();
360362
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 ));
364367 client ().execute (CreateAndFollowIndexAction .INSTANCE , new CreateAndFollowIndexAction .Request (followRequest )).get ();
365368
366369 long maxNumDocsReplicated = Math .min (1000 , randomLongBetween (followRequest .getMaxBatchOperationCount (),
@@ -447,7 +450,7 @@ public void testFollowNonExistentIndex() throws Exception {
447450 .actionGet ());
448451 }
449452
450- public void testFollowIndex_lowMaxTranslogBytes () throws Exception {
453+ public void testFollowIndexMaxOperationSizeInBytes () throws Exception {
451454 final String leaderIndexSettings = getIndexSettings (1 , between (0 , 1 ),
452455 singletonMap (IndexSettings .INDEX_SOFT_DELETES_SETTING .getKey (), "true" ));
453456 assertAcked (client ().admin ().indices ().prepareCreate ("index1" ).setSource (leaderIndexSettings , XContentType .JSON ));
@@ -460,8 +463,8 @@ public void testFollowIndex_lowMaxTranslogBytes() throws Exception {
460463 client ().prepareIndex ("index1" , "doc" , Integer .toString (i )).setSource (source , XContentType .JSON ).get ();
461464 }
462465
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 );
465468 final CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
466469 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
467470
@@ -489,25 +492,21 @@ public void testDontFollowTheWrongIndex() throws Exception {
489492 assertAcked (client ().admin ().indices ().prepareCreate ("index3" ).setSource (leaderIndexSettings , XContentType .JSON ));
490493 ensureGreen ("index3" );
491494
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" );
494496 CreateAndFollowIndexAction .Request createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
495497 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
496498
497- followRequest = new FollowIndexAction .Request ("index3" , "index4" , 1024 , 1 , 1024L ,
498- 1 , 10240 , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
499+ followRequest = createFollowRequest ("index3" , "index4" );
499500 createAndFollowRequest = new CreateAndFollowIndexAction .Request (followRequest );
500501 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
501502 unfollowIndex ("index2" , "index4" );
502503
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" );
505505 Exception e = expectThrows (IllegalArgumentException .class ,
506506 () -> client ().execute (FollowIndexAction .INSTANCE , wrongRequest1 ).actionGet ());
507507 assertThat (e .getMessage (), containsString ("follow index [index4] should reference" ));
508508
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" );
511510 e = expectThrows (IllegalArgumentException .class , () -> client ().execute (FollowIndexAction .INSTANCE , wrongRequest2 ).actionGet ());
512511 assertThat (e .getMessage (), containsString ("follow index [index2] should reference" ));
513512 }
@@ -716,10 +715,12 @@ private void assertSameDocCount(String index1, String index2) throws Exception {
716715 }, 60 , TimeUnit .SECONDS );
717716 }
718717
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 ;
724725 }
725726}
0 commit comments