athanatos 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_r239954569
 
 

 ##########
 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;
 
 Review comment:
   Yeah, but I wanted to unify the getFCForEntryInternal logic and you can't 
return a compound structure without it being on the heap.  We could pool it, or 
use a per-thread preallocated holder, or w/e, but this is simple enough for now 
unless you think it's worth adding additional complexity.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to