/** * Traverse the pages for a given ledger in memory and find the highest entry amongst these * pages * * @param ledgerId Ledger id * @returns last entry in the in memory pages */ private long getLastEntryInMem(long ledgerId) { long lastEntry = 0; // Find the last entry in the cache ConcurrentMap<Long, LedgerEntryPage> map = pages.get(ledgerId); if (map != null) { for (LedgerEntryPage lep : map.values()) { if (lep.getMaxPossibleEntry() < lastEntry) { continue; } lep.usePage(); long highest = lep.getLastEntry(); if (highest > lastEntry) { lastEntry = highest; } lep.releasePage(); } } return lastEntry; }