@Override public void asyncReadEntry(ReadHandle lh, long firstEntry, long lastEntry, boolean isSlowestReader, final ReadEntriesCallback callback, Object ctx) { lh.readAsync(firstEntry, lastEntry).whenComplete( (ledgerEntries, exception) -> { if (exception != null) { callback.readEntriesFailed(createManagedLedgerException(exception), ctx); return; } List<Entry> entries = Lists.newArrayList(); long totalSize = 0; try { for (LedgerEntry e : ledgerEntries) { // Insert the entries at the end of the list (they will be unsorted for now) EntryImpl entry = EntryImpl.create(e); entries.add(entry); totalSize += entry.getLength(); } } finally { ledgerEntries.close(); } mlFactoryMBean.recordCacheMiss(entries.size(), totalSize); ml.mbean.addReadEntriesSample(entries.size(), totalSize); callback.readEntriesComplete(entries, null); }); }
ledgerEntries.close();
ledgerEntries.close();
@Override public void onSuccess(LedgerEntries ledgerEntries) { long entryId = -1L; for (org.apache.bookkeeper.client.api.LedgerEntry entry : ledgerEntries) { resultList.add(new LedgerEntry((LedgerEntryImpl) entry)); entryId = entry.getEntryId(); } try { ledgerEntries.close(); } catch (Exception e) { // bk should not throw any exceptions here } ++entryId; readNext(entryId); }
@Override public void asyncReadEntry(ReadHandle lh, long firstEntry, long lastEntry, boolean isSlowestReader, final ReadEntriesCallback callback, Object ctx) { lh.readAsync(firstEntry, lastEntry).whenComplete( (ledgerEntries, exception) -> { if (exception != null) { callback.readEntriesFailed(createManagedLedgerException(exception), ctx); return; } List<Entry> entries = Lists.newArrayList(); long totalSize = 0; try { for (LedgerEntry e : ledgerEntries) { // Insert the entries at the end of the list (they will be unsorted for now) EntryImpl entry = EntryImpl.create(e); entries.add(entry); totalSize += entry.getLength(); } } finally { ledgerEntries.close(); } mlFactoryMBean.recordCacheMiss(entries.size(), totalSize); ml.mbean.addReadEntriesSample(entries.size(), totalSize); callback.readEntriesComplete(entries, null); }); }
ledgerEntries.close();
ledgerEntries.close();