hangc0276 commented on code in PR #3339:
URL: https://github.com/apache/bookkeeper/pull/3339#discussion_r929505521
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java:
##########
@@ -1622,13 +1622,33 @@ private void
waitForLedgersToBeReplicated(Collection<Long> ledgers, BookieId thi
LedgerManager ledgerManager) throws InterruptedException,
TimeoutException {
int maxSleepTimeInBetweenChecks = 10 * 60 * 1000; // 10 minutes
int sleepTimePerLedger = 10 * 1000; // 10 secs
+ int rereplicateBackoffMs = 10 * 1000; // 10 secs
+ int backOffCount = 0;
Predicate<Long> validateBookieIsNotPartOfEnsemble = ledgerId ->
!areEntriesOfLedgerStoredInTheBookie(ledgerId,
thisBookieAddress, ledgerManager);
while (!ledgers.isEmpty()) {
LOG.info("Count of Ledgers which need to be rereplicated: {}",
ledgers.size());
int sleepTimeForThisCheck = (long) ledgers.size() *
sleepTimePerLedger > maxSleepTimeInBetweenChecks
? maxSleepTimeInBetweenChecks : ledgers.size() *
sleepTimePerLedger;
- Thread.sleep(sleepTimeForThisCheck);
+ long nextValidateTime = System.currentTimeMillis() +
sleepTimeForThisCheck;
Review Comment:
Could you use a backoff policy to simplify the code? You can refer to:
https://github.com/apache/pulsar/blob/master/pulsar-client/src/main/java/org/apache/pulsar/client/impl/Backoff.java
--
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]