Skip to content

Commit

Permalink
Fix read entires
Browse files Browse the repository at this point in the history
  • Loading branch information
mattisonchao committed Aug 4, 2022
1 parent 8a5e1c0 commit 2cc107d
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,19 @@ public void asyncReadEntry(ReadHandle lh, long firstEntry, long lastEntry, boole
long totalCachedSize = entryCacheManager.getRange(ledgerId, firstEntry, lastEntry, cachedEntries);

if (cachedEntries.size() == entriesToRead) {
final List<Entry> entriesToReturn = Lists.newArrayListWithExpectedSize(entriesToRead);
// All entries found in cache
entryCacheManager.getFactoryMBean().recordCacheHits(entriesToRead, totalCachedSize);
for (Entry entry : cachedEntries) {
entriesToReturn.add(EntryImpl.create((EntryImpl) entry));
entry.release();
}
// All entries found in cache
entryCacheManager.getFactoryMBean().recordCacheHits(entriesToReturn.size(), totalCachedSize);
if (log.isDebugEnabled()) {
log.debug("[{}] Ledger {} -- Found in cache entries: {}-{}", ml.getName(), ledgerId, firstEntry,
lastEntry);
}

callback.readEntriesComplete(cachedEntries, ctx);
callback.readEntriesComplete(entriesToReturn, ctx);

} else {
if (!cachedEntries.isEmpty()) {
Expand Down

0 comments on commit 2cc107d

Please sign in to comment.