@@ -437,8 +437,13 @@ protected void updateCompactionCompleted(TExternalCompactionJob job, TCompaction
437
437
* @throws RetriesExceededException thrown when retries have been exceeded
438
438
*/
439
439
protected TExternalCompactionJob getNextJob (Supplier <UUID > uuid ) throws RetriesExceededException {
440
+ final long startingWaitTime =
441
+ getConfiguration ().getTimeInMillis (Property .COMPACTOR_MIN_JOB_WAIT_TIME );
442
+ final long maxWaitTime =
443
+ getConfiguration ().getTimeInMillis (Property .COMPACTOR_MAX_JOB_WAIT_TIME );
444
+
440
445
RetryableThriftCall <TExternalCompactionJob > nextJobThriftCall =
441
- new RetryableThriftCall <>(1000 , RetryableThriftCall . MAX_WAIT_TIME , 0 , () -> {
446
+ new RetryableThriftCall <>(startingWaitTime , maxWaitTime , 0 , () -> {
442
447
Client coordinatorClient = getCoordinatorClient ();
443
448
try {
444
449
ExternalCompactionId eci = ExternalCompactionId .generate (uuid .get ());
@@ -579,12 +584,14 @@ protected Supplier<UUID> getNextId() {
579
584
protected long getWaitTimeBetweenCompactionChecks () {
580
585
// get the total number of compactors assigned to this queue
581
586
int numCompactors = ExternalCompactionUtil .countCompactors (queueName , getContext ());
582
- // Aim for around 3 compactors checking in every second
583
- long sleepTime = numCompactors * 1000L / 3 ;
584
- // Ensure a compactor sleeps at least around a second
585
- sleepTime = Math .max (1000 , sleepTime );
586
- // Ensure a compactor sleep not too much more than 5 mins
587
- sleepTime = Math .min (300_000L , sleepTime );
587
+ long minWait = getConfiguration ().getTimeInMillis (Property .COMPACTOR_MIN_JOB_WAIT_TIME );
588
+ // Aim for around 3 compactors checking in per min wait time.
589
+ long sleepTime = numCompactors * minWait / 3 ;
590
+ // Ensure a compactor waits at least the minimum time
591
+ sleepTime = Math .max (minWait , sleepTime );
592
+ // Ensure a sleeping compactor has a configurable max sleep time
593
+ sleepTime = Math .min (getConfiguration ().getTimeInMillis (Property .COMPACTOR_MAX_JOB_WAIT_TIME ),
594
+ sleepTime );
588
595
// Add some random jitter to the sleep time, that averages out to sleep time. This will spread
589
596
// compactors out evenly over time.
590
597
sleepTime = (long ) (.9 * sleepTime + sleepTime * .2 * RANDOM .get ().nextDouble ());
0 commit comments