StevenLuMT commented on code in PR #2942:
URL: https://github.com/apache/bookkeeper/pull/2942#discussion_r931284700


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/AbstractLogCompactor.java:
##########
@@ -74,8 +78,32 @@ public static class Throttler {
         }
 
         // acquire. if bybytes: bytes of this entry; if byentries: 1.
-        public void acquire(int permits) {
-            rateLimiter.acquire(this.isThrottleByBytes ? permits : 1);
+        boolean tryAcquire(int permits, long timeout, TimeUnit unit) {
+            return rateLimiter.tryAcquire(this.isThrottleByBytes ? permits : 
1, timeout, unit);
+        }
+
+        // GC thread will check the status for the rate limiter
+        // If the compactor is being stopped by other threads,
+        // and the GC thread is still limited, the compact task will be 
stopped.
+        public void acquire(int permits) throws IOException {
+            long timeout = 100;
+            long start = System.currentTimeMillis();
+            while (!tryAcquire(permits, timeout, TimeUnit.MILLISECONDS)) {

Review Comment:
   MILLISECONDS in tryAcquire
   but TimeUnit.NANOSECONDS.sleep(timeout)?
   mistake??? @wenbingshen 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to