接口 EntryCache

所有超级接口:
Comparable<EntryCache>
所有已知实现类:
EntryCacheDisabled, RangeEntryCacheImpl

public interface EntryCache extends 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).
  • 方法详细资料

    • getName

      String getName()
      返回:
      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

      参数:
      entry - the entry to be cached
      返回:
      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.
      参数:
      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.
      参数:
      ledgerId - the ledger id
    • clear

      void clear()
      Remove all the entries from the cache.
    • evictEntries

      org.apache.commons.lang3.tuple.Pair<Integer,Long> evictEntries(long sizeToFree)
      Force the cache to drop entries to free space.
      参数:
      sizeToFree - the total memory size to free
      返回:
      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, 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.

      参数:
      lh - the ledger handle
      firstEntry - 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 stream
      callback - the callback object that will be notified when read is done
      ctx - 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.

      参数:
      lh - the ledger handle
      position - position to read the entry from
      callback - the callback object that will be notified when read is done
      ctx - the context object
    • getSize

      long getSize()
      Get the total size in bytes of all the entries stored in this cache.
      返回:
      the size of the entry cache