merlimat commented on a change in pull request #1819: ISSUE-1770: Add local
checker for Sorted/InterleavedLedgerStorage
URL: https://github.com/apache/bookkeeper/pull/1819#discussion_r330316439
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
##########
@@ -724,12 +807,42 @@ public ByteBuf internalReadEntry(long ledgerId, long
entryId, long location)
}
if (entrySize < MIN_SANE_ENTRY_SIZE) {
LOG.error("Read invalid entry length {}", entrySize);
- throw new IOException("Invalid entry length " + entrySize);
+ throw new
EntryLookupException.InvalidEntryLengthException(ledgerId, entryId, entryLogId,
pos);
+ }
+
+ long thisLedgerId = sizeBuff.getLong(4);
+ long thisEntryId = sizeBuff.getLong(12);
+ if (thisLedgerId != ledgerId || thisEntryId != entryId) {
+ throw new EntryLookupException.WrongEntryException(
+ thisEntryId, thisLedgerId, ledgerId, entryId, entryLogId,
pos);
}
+ return new EntryLogEntry(entrySize, fc);
+ }
+
+ void checkEntry(long ledgerId, long entryId, long location) throws
EntryLookupException, IOException {
+ long entryLogId = logIdForOffset(location);
+ long pos = location & 0xffffffffL;
+ getFCForEntryInternal(ledgerId, entryId, entryLogId, pos);
+ }
- ByteBuf data = PooledByteBufAllocator.DEFAULT.directBuffer(entrySize,
entrySize);
- int rc = readFromLogChannel(entryLogId, fc, data, pos);
- if (rc != entrySize) {
+ public ByteBuf internalReadEntry(long ledgerId, long entryId, long
location)
+ throws IOException, Bookie.NoEntryException {
+ long entryLogId = logIdForOffset(location);
+ long pos = location & 0xffffffffL;
+
+ final EntryLogEntry entry;
+ try {
+ entry = getFCForEntryInternal(ledgerId, entryId, entryLogId, pos);
Review comment:
It seems to be that a less expensive way would to be to just an enum code to
signal a particular error and also avoid the `EntryLogEntry` allocation for
each read.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services