Skip to content

Commit

Permalink
fix checkAllLedgersDuration compute (apache#2970)
Browse files Browse the repository at this point in the history
  • Loading branch information
lordcheng10 authored and Anup Ghatage committed Jul 12, 2024
1 parent 6a4305e commit 3474b7c
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -796,18 +796,20 @@ private void scheduleCheckAllLedgersTask(){
executor.scheduleAtFixedRate(safeRun(new Runnable() {
@Override
public void run() {
Stopwatch stopwatch = Stopwatch.createStarted();
boolean checkSuccess = false;
try {
if (!ledgerUnderreplicationManager.isLedgerReplicationEnabled()) {
LOG.info("Ledger replication disabled, skipping checkAllLedgers");
return;
}

Stopwatch stopwatch = Stopwatch.createStarted();
LOG.info("Starting checkAllLedgers");
checkAllLedgers();
long checkAllLedgersDuration = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
LOG.info("Completed checkAllLedgers in {} milliSeconds", checkAllLedgersDuration);
checkAllLedgersTime.registerSuccessfulEvent(checkAllLedgersDuration, TimeUnit.MILLISECONDS);
checkSuccess = true;
} catch (KeeperException ke) {
LOG.error("Exception while running periodic check", ke);
} catch (InterruptedException ie) {
Expand All @@ -819,6 +821,11 @@ public void run() {
LOG.error("I/O exception running periodic check", ioe);
} catch (ReplicationException.UnavailableException ue) {
LOG.error("Underreplication manager unavailable running periodic check", ue);
} finally {
if (!checkSuccess) {
long checkAllLedgersDuration = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
checkAllLedgersTime.registerFailedEvent(checkAllLedgersDuration, TimeUnit.MILLISECONDS);
}
}
}
}), initialDelay, interval, TimeUnit.SECONDS);
Expand Down

0 comments on commit 3474b7c

Please sign in to comment.