public static EntryImpl create(LedgerEntry ledgerEntry) { EntryImpl entry = RECYCLER.get(); entry.ledgerId = ledgerEntry.getLedgerId(); entry.entryId = ledgerEntry.getEntryId(); entry.data = ledgerEntry.getEntryBuffer(); entry.data.retain(); entry.setRefCnt(1); return entry; }
/** * {@inheritDoc} */ @Override public LedgerEntry getEntry(long entryId) { checkNotNull(entries, "entries has been recycled"); long firstId = entries.get(0).getEntryId(); long lastId = entries.get(entries.size() - 1).getEntryId(); if (entryId < firstId || entryId > lastId) { throw new IndexOutOfBoundsException("required index: " + entryId + " is out of bounds: [ " + firstId + ", " + lastId + " ]."); } return entries.get((int) (entryId - firstId)); }
@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); }
public static EntryImpl create(LedgerEntry ledgerEntry) { EntryImpl entry = RECYCLER.get(); entry.ledgerId = ledgerEntry.getLedgerId(); entry.entryId = ledgerEntry.getEntryId(); entry.data = ledgerEntry.getEntryBuffer(); entry.data.retain(); entry.setRefCnt(1); return entry; }
public static LedgerEntryImpl duplicate(LedgerEntry entry) { return create( entry.getLedgerId(), entry.getEntryId(), entry.getLength(), entry.getEntryBuffer().retainedSlice()); }