@ SneakyThrows ( DurableDataLogException . class ) private long fetchLastAddConfirmed ( WriteLedger writeLedger , Map < Long , Long > lastAddsConfirmed ) { long ledgerId = writeLedger . ledger . getId ( ) ; long lac = lastAddsConfirmed . getOrDefault ( ledgerId , - 1L ) ; long traceId = LoggerHelpers . traceEnterWithContext ( log , this . traceObjectId , "fetchLastAddConfirmed" , ledgerId , lac ) ; if ( lac < 0 ) { if ( writeLedger . isRolledOver ( ) ) { // This close was not due to failure, rather a rollover - hence lastAddConfirmed can be relied upon. lac = writeLedger . ledger . getLastAddConfirmed ( ) ; } else { // Ledger got closed. This could be due to some external factor, and lastAddConfirmed can't be relied upon. // We need to re-open the ledger to get fresh data. lac = Ledgers . readLastAddConfirmed ( ledgerId , this . bookKeeper , this . config ) ; } lastAddsConfirmed . put ( ledgerId , lac ) ; log . info ( "{}: Fetched actual LastAddConfirmed ({}) for LedgerId {}." , this . traceObjectId , lac , ledgerId ) ; } LoggerHelpers . traceLeave ( log , this . traceObjectId , "fetchLastAddConfirmed" , traceId , ledgerId , lac ) ; return lac ; }
Reliably gets the LastAddConfirmed for the WriteLedger