@Override public int compareTo(EntryCache other) { return Longs.compare(getSize(), other.getSize()); }
public EntryCache getEntryCache(ManagedLedgerImpl ml) { if (maxSize == 0) { // Cache is disabled return new EntryCacheDisabled(ml); } EntryCache newEntryCache = new EntryCacheImpl(this, ml); EntryCache currentEntryCache = caches.putIfAbsent(ml.getName(), newEntryCache); if (currentEntryCache != null) { return currentEntryCache; } else { return newEntryCache; } }
@Override public void asyncReadEntry(ReadHandle lh, PositionImpl position, final ReadEntryCallback callback, final Object ctx) { try { asyncReadEntry0(lh, position, callback, ctx); } catch (Throwable t) { log.warn("failed to read entries for {}-{}", lh.getId(), position, t); // invalidate all entries related to ledger from the cache (it might happen if entry gets corrupt // (entry.data is already deallocate due to any race-condition) so, invalidate cache and next time read from // the bookie) invalidateAllEntries(lh.getId()); callback.readEntryFailed(createManagedLedgerException(t), ctx); } }
@Override public void asyncReadEntry(ReadHandle lh, long firstEntry, long lastEntry, boolean isSlowestReader, final ReadEntriesCallback callback, Object ctx) { try { asyncReadEntry0(lh, firstEntry, lastEntry, isSlowestReader, callback, ctx); } catch (Throwable t) { log.warn("failed to read entries for {}--{}-{}", lh.getId(), firstEntry, lastEntry, t); // invalidate all entries related to ledger from the cache (it might happen if entry gets corrupt // (entry.data is already deallocate due to any race-condition) so, invalidate cache and next time read from // the bookie) invalidateAllEntries(lh.getId()); callback.readEntriesFailed(createManagedLedgerException(t), ctx); } }
public EntryCache getEntryCache(ManagedLedgerImpl ml) { if (maxSize == 0) { // Cache is disabled return new EntryCacheDisabled(ml); } EntryCache newEntryCache = new EntryCacheImpl(this, ml); EntryCache currentEntryCache = caches.putIfAbsent(ml.getName(), newEntryCache); if (currentEntryCache != null) { return currentEntryCache; } else { return newEntryCache; } }
assertEquals((5 * totalInsertedEntries), entryCache.getSize()); log.info("expected, found : {}, {}", (5 * (totalInsertedEntries - readEntries)), entryCache.getSize()); assertEquals((5 * (totalInsertedEntries - readEntries)), entryCache.getSize()); assertEquals((5 * (remainingEntries)), entryCache.getSize()); assertEquals(0, entryCache.getSize());
@Override public void asyncReadEntry(ReadHandle lh, PositionImpl position, final ReadEntryCallback callback, final Object ctx) { try { asyncReadEntry0(lh, position, callback, ctx); } catch (Throwable t) { log.warn("failed to read entries for {}-{}", lh.getId(), position, t); // invalidate all entries related to ledger from the cache (it might happen if entry gets corrupt // (entry.data is already deallocate due to any race-condition) so, invalidate cache and next time read from // the bookie) invalidateAllEntries(lh.getId()); callback.readEntryFailed(createManagedLedgerException(t), ctx); } }
public EntryCache getEntryCache(ManagedLedgerImpl ml) { if (maxSize == 0) { // Cache is disabled return new EntryCacheDisabled(ml); } EntryCache newEntryCache = new EntryCacheImpl(this, ml); EntryCache currentEntryCache = caches.putIfAbsent(ml.getName(), newEntryCache); if (currentEntryCache != null) { return currentEntryCache; } else { return newEntryCache; } }
@Override public int compareTo(EntryCache other) { return Longs.compare(getSize(), other.getSize()); }
@Override public void asyncReadEntry(ReadHandle lh, long firstEntry, long lastEntry, boolean isSlowestReader, final ReadEntriesCallback callback, Object ctx) { try { asyncReadEntry0(lh, firstEntry, lastEntry, isSlowestReader, callback, ctx); } catch (Throwable t) { log.warn("failed to read entries for {}--{}-{}", lh.getId(), firstEntry, lastEntry, t); // invalidate all entries related to ledger from the cache (it might happen if entry gets corrupt // (entry.data is already deallocate due to any race-condition) so, invalidate cache and next time read from // the bookie) invalidateAllEntries(lh.getId()); callback.readEntriesFailed(createManagedLedgerException(t), ctx); } }
@Override public int compareTo(EntryCache other) { return Longs.compare(getSize(), other.getSize()); }