shustsud commented on a change in pull request #2813:
URL: https://github.com/apache/bookkeeper/pull/2813#discussion_r723770684
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ScanAndCompareGarbageCollector.java
##########
@@ -291,4 +288,55 @@ public void gc(GarbageCleaner garbageCleaner) {
bkActiveledgers.removeAll(overReplicatedLedgers);
return overReplicatedLedgers;
}
+
+ private Set<Long> preCheckOverReplicatedLedgers(Set<Long> bkActiveLedgers)
throws InterruptedException {
+ final Set<Long> candidateOverReplicatedLedgers = Sets.newHashSet();
+ final Semaphore semaphore = new Semaphore(MAX_CONCURRENT_ZK_REQUESTS);
+ final CountDownLatch latch = new
CountDownLatch(bkActiveLedgers.size());
+
+ for (final Long ledgerId : bkActiveLedgers) {
+ try {
+ semaphore.acquire();
+ ledgerManager.readLedgerMetadata(ledgerId)
+ .whenComplete((metadata, exception) -> {
+ try {
+ if (exception == null) {
+ if
(isNotBookieIncludedInLedgerEnsembles(metadata)) {
+
candidateOverReplicatedLedgers.add(ledgerId);
+ }
+ }
+ } finally {
+ semaphore.release();
+ latch.countDown();
+ }
+ });
+ } catch (Throwable t) {
+ LOG.error("Exception when iterating through the ledgers to
pre-check for over-replication", t);
+ latch.countDown();
+ }
+ }
+ latch.await();
+ LOG.info("Finished pre-check over-replicated ledgers.
candidateOverReplicatedLedgersSize={}",
Review comment:
Fixed.
--
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]