Skip to content

Commit

Permalink
fix checkAllLedgersDuration compute (apache#2970)
Browse files Browse the repository at this point in the history
(cherry picked from commit dc2be02)
  • Loading branch information
lordcheng10 authored and hangc0276 committed Nov 7, 2022
1 parent 8ce6538 commit cbaf9f8
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -763,18 +763,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 (InterruptedException ie) {
Thread.currentThread().interrupt();
LOG.error("Interrupted while running periodic check", ie);
Expand All @@ -787,6 +789,11 @@ public void run() {
submitShutdownTask();
} 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 cbaf9f8

Please sign in to comment.