This is an automated email from the ASF dual-hosted git repository.

ddanielr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 9f430a26956449133d13c1a35c367df7ce33dc7e
Merge: 978f8b9eca 3298d6db89
Author: Daniel Roberts <ddani...@gmail.com>
AuthorDate: Fri Feb 16 22:12:55 2024 +0000

    Merge branch '2.1'

 .../org/apache/accumulo/core/conf/Property.java     | 10 ++++++++++
 .../accumulo/coordinator/CompactionCoordinator.java |  5 ++---
 .../org/apache/accumulo/compactor/Compactor.java    | 21 ++++++++++++++-------
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --cc 
server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
index 00956edbf1,1434d2a1f1..b81c30dee3
--- 
a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
+++ 
b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
@@@ -579,15 -592,17 +584,17 @@@ public class Compactor extends Abstract
    protected long getWaitTimeBetweenCompactionChecks() {
      // get the total number of compactors assigned to this queue
      int numCompactors = ExternalCompactionUtil.countCompactors(queueName, 
getContext());
-     // Aim for around 3 compactors checking in every second
-     long sleepTime = numCompactors * 1000L / 3;
-     // Ensure a compactor sleeps at least around a second
-     sleepTime = Math.max(1000, sleepTime);
-     // Ensure a compactor sleep not too much more than 5 mins
-     sleepTime = Math.min(300_000L, sleepTime);
+     long minWait = 
getConfiguration().getTimeInMillis(Property.COMPACTOR_MIN_JOB_WAIT_TIME);
+     // Aim for around 3 compactors checking in per min wait time.
+     long sleepTime = numCompactors * minWait / 3;
+     // Ensure a compactor waits at least the minimum time
+     sleepTime = Math.max(minWait, sleepTime);
+     // Ensure a sleeping compactor has a configurable max sleep time
+     sleepTime = 
Math.min(getConfiguration().getTimeInMillis(Property.COMPACTOR_MAX_JOB_WAIT_TIME),
+         sleepTime);
      // Add some random jitter to the sleep time, that averages out to sleep 
time. This will spread
      // compactors out evenly over time.
 -    sleepTime = (long) (.9 * sleepTime + sleepTime * .2 * 
random.nextDouble());
 +    sleepTime = (long) (.9 * sleepTime + sleepTime * .2 * 
RANDOM.get().nextDouble());
      LOG.trace("Sleeping {}ms based on {} compactors", sleepTime, 
numCompactors);
      return sleepTime;
    }

Reply via email to