Interface EntryCache
- All Superinterfaces:
Comparable<EntryCache>
- All Known Implementing Classes:
EntryCacheDisabled,RangeEntryCacheImpl
Cache of entries used by a single ManagedLedger. An EntryCache is compared to other EntryCache instances using their
size (the memory that is occupied by each of them).
-
Method Summary
Modifier and TypeMethodDescriptionvoidasyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle lh, long firstEntry, long lastEntry, boolean shouldCacheEntry, AsyncCallbacks.ReadEntriesCallback callback, Object ctx) Read entries from the cache or from bookkeeper.voidasyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle lh, PositionImpl position, AsyncCallbacks.ReadEntryCallback callback, Object ctx) Read entry at given position from the cache or from bookkeeper.voidclear()Remove all the entries from the cache.evictEntries(long sizeToFree) Force the cache to drop entries to free space.getName()longgetSize()Get the total size in bytes of all the entries stored in this cache.booleanInsert an entry in the cache.voidinvalidateAllEntries(long ledgerId) Remove from the cache all the entries belonging to a specific ledger.voidinvalidateEntries(PositionImpl lastPosition) Remove from cache all the entries related to a ledger up to lastPosition excluded.voidinvalidateEntriesBeforeTimestamp(long timestamp) Methods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
getName
String getName()- Returns:
- the name of the cache
-
insert
Insert an entry in the cache. If the overall limit have been reached, this will trigger the eviction of other entries, possibly from other EntryCache instances- Parameters:
entry- the entry to be cached- Returns:
- whether the entry was inserted in cache
-
invalidateEntries
Remove from cache all the entries related to a ledger up to lastPosition excluded.- Parameters:
lastPosition- the position of the last entry to be invalidated (non-inclusive)
-
invalidateEntriesBeforeTimestamp
void invalidateEntriesBeforeTimestamp(long timestamp) -
invalidateAllEntries
void invalidateAllEntries(long ledgerId) Remove from the cache all the entries belonging to a specific ledger.- Parameters:
ledgerId- the ledger id
-
clear
void clear()Remove all the entries from the cache. -
evictEntries
Force the cache to drop entries to free space.- Parameters:
sizeToFree- the total memory size to free- Returns:
- a pair containing the number of entries evicted and their total size
-
asyncReadEntry
void asyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle lh, long firstEntry, long lastEntry, boolean shouldCacheEntry, AsyncCallbacks.ReadEntriesCallback callback, Object ctx) Read entries from the cache or from bookkeeper. Get the entry data either from cache or bookkeeper and mixes up the results in a single list.- Parameters:
lh- the ledger handlefirstEntry- the first entry to read (inclusive)lastEntry- the last entry to read (inclusive)shouldCacheEntry- whether the read entry should be cachedcallback- the callback object that will be notified when read is donectx- the context object
-
asyncReadEntry
void asyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle lh, PositionImpl position, AsyncCallbacks.ReadEntryCallback callback, Object ctx) Read entry at given position from the cache or from bookkeeper. Get the entry data either from cache or bookkeeper and mixes up the results in a single list.- Parameters:
lh- the ledger handleposition- position to read the entry fromcallback- the callback object that will be notified when read is donectx- the context object
-
getSize
long getSize()Get the total size in bytes of all the entries stored in this cache.- Returns:
- the size of the entry cache
-