@@ -472,12 +472,17 @@ public void testConcurrentSplit() throws Exception {
472
472
splits .add (new Text (String .format ("r:%04d" , i )));
473
473
}
474
474
475
- // wait a bit for some tablets to have files selected, it possible the compaction have
476
- // completed before this so do not wait long
477
- Wait .waitFor (
478
- () -> countTablets (tableName , tabletMetadata -> tabletMetadata .getSelectedFiles () != null )
479
- > 0 ,
480
- 3000 , 10 );
475
+ // Wait a bit for some tablets to have files selected, it possible the compaction have
476
+ // completed before this so do not wait long. Once files are selected compactions can start.
477
+ // This speed bump is an attempt to increase the chance that splits and compactions run
478
+ // concurrently. Wait.waitFor() is not used here because it will throw an exception if the
479
+ // time limit is exceeded.
480
+ long startTime = System .nanoTime ();
481
+ while (System .nanoTime () - startTime < SECONDS .toNanos (3 )
482
+ && countTablets (tableName , tabletMetadata -> tabletMetadata .getSelectedFiles () != null )
483
+ == 0 ) {
484
+ Thread .sleep (10 );
485
+ }
481
486
482
487
// add 10 more splits to the table
483
488
c .tableOperations ().addSplits (tableName , splits );
@@ -487,12 +492,16 @@ public void testConcurrentSplit() throws Exception {
487
492
splits .add (new Text (String .format ("r:%04d" , i )));
488
493
}
489
494
490
- // wait a bit for some tablets to be compacted, it possible the compaction have completed
491
- // before this so do not wait long
492
- Wait .waitFor (
493
- () -> countTablets (tableName , tabletMetadata -> !tabletMetadata .getCompacted ().isEmpty ())
494
- > 0 ,
495
- 3000 , 10 );
495
+ // Wait a bit for some tablets to be compacted, it possible the compaction have completed
496
+ // before this so do not wait long. Wait.waitFor() is not used here because it will throw an
497
+ // exception if the time limit is exceeded. This is just a speed bump, its ok if the condition
498
+ // is not met within the time limit.
499
+ startTime = System .nanoTime ();
500
+ while (System .nanoTime () - startTime < SECONDS .toNanos (3 )
501
+ && countTablets (tableName , tabletMetadata -> !tabletMetadata .getCompacted ().isEmpty ())
502
+ == 0 ) {
503
+ Thread .sleep (10 );
504
+ }
496
505
497
506
// add 80 more splits to the table
498
507
c .tableOperations ().addSplits (tableName , splits );
0 commit comments