Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public long getLastEntryInLedger(long ledgerId) throws IOException {
}

private long getLastEntryInLedgerInternal(long ledgerId) throws IOException {
// Search the last entry in storage would be time consume in the case of empty ledger.
// check if ledge is empty first.
long entryLocation = getLocation(ledgerId, 0);
if (entryLocation == 0) {
log.warn("Tried to get last entry from an empty ledger: {}", ledgerId);
throw new Bookie.NoEntryException(ledgerId, -1);
}

LongPairWrapper maxEntryId = LongPairWrapper.get(ledgerId, Long.MAX_VALUE);

// Search the last entry in storage
Expand Down