wenbingshen commented on code in PR #2942:
URL: https://github.com/apache/bookkeeper/pull/2942#discussion_r930582777
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/AbstractLogCompactor.java:
##########
@@ -66,6 +70,8 @@ public void cleanUpAndRecover() {}
public static class Throttler {
private final RateLimiter rateLimiter;
private final boolean isThrottleByBytes;
+ private final AtomicBoolean cancelled = new AtomicBoolean(false);
+ private final AtomicBoolean throttlerInterrupted = new
AtomicBoolean(false);
Review Comment:
Thanks for your review.I think `throttlerInterrupted` can be removed.
Because we can use
`org.apache.bookkeeper.bookie.GarbageCollectorThread#running` in the test to
determine whether the GC thread is closed, because if the `throttler` is not
interrupted, the `compact` will not end, and the GC thread will always be stuck
in `shutdown`.
```java
public synchronized void shutdown() throws InterruptedException {
if (!this.running) {
return;
}
LOG.info("Shutting down GarbageCollectorThread");
throttler.cancelledAcquire();
compactor.throttler.cancelledAcquire();
while (!compacting.compareAndSet(false, true)) {
// Wait till the thread stops compacting
Thread.sleep(100);
}
this.running = false;
// Interrupt GC executor thread
gcExecutor.shutdownNow();
try {
entryLogMetaMap.close();
} catch (Exception e) {
LOG.warn("Failed to close entryLog metadata-map", e);
}
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]