Interface EntryCache
-
- All Superinterfaces:
java.lang.Comparable<EntryCache>
- All Known Implementing Classes:
EntryCacheImpl,EntryCacheManager.EntryCacheDisabled
public interface EntryCache extends java.lang.Comparable<EntryCache>
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidasyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle lh, long firstEntry, long lastEntry, boolean isSlowestReader, AsyncCallbacks.ReadEntriesCallback callback, java.lang.Object ctx)Read entries from the cache or from bookkeeper.voidasyncReadEntry(org.apache.bookkeeper.client.api.ReadHandle lh, PositionImpl position, AsyncCallbacks.ReadEntryCallback callback, java.lang.Object ctx)Read entry at given position from the cache or from bookkeeper.voidclear()Remove all the entries from the cache.org.apache.commons.lang3.tuple.Pair<java.lang.Integer,java.lang.Long>evictEntries(long sizeToFree)Force the cache to drop entries to free space.java.lang.StringgetName()longgetSize()Get the total size in bytes of all the entries stored in this cache.booleaninsert(EntryImpl entry)Insert 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 included.voidinvalidateEntriesBeforeTimestamp(long timestamp)
-
-
-
Method Detail
-
getName
java.lang.String getName()
- Returns:
- the name of the cache
-
insert
boolean insert(EntryImpl entry)
Insert an entry in the cache. If the overall limit have been reached, this will triggered 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
void invalidateEntries(PositionImpl lastPosition)
Remove from cache all the entries related to a ledger up to lastPosition included.- 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
org.apache.commons.lang3.tuple.Pair<java.lang.Integer,java.lang.Long> evictEntries(long sizeToFree)
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 isSlowestReader, AsyncCallbacks.ReadEntriesCallback callback, java.lang.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)isSlowestReader- whether the reader cursor is the most far behind in the streamcallback- 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, java.lang.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
-
-