Class WriteCache
java.lang.Object
org.apache.bookkeeper.bookie.storage.ldb.WriteCache
- All Implemented Interfaces:
Closeable,AutoCloseable
Write cache implementation.
The write cache will allocate the requested size from direct memory and it will break it down into multiple segments.
The entries are appended in a common buffer and indexed though a hashmap, until the cache is cleared.
There is the possibility to iterate through the stored entries in an ordered way, by (ledgerId, entry).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceConsumer that is used to scan the entire write cache. -
Constructor Summary
ConstructorsConstructorDescriptionWriteCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize) WriteCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize, int maxSegmentSize) -
Method Summary
Modifier and TypeMethodDescription(package private) static intalign64(int size) voidclear()voidclose()longcount()voiddeleteLedger(long ledgerId) voidforEach(WriteCache.EntryConsumer consumer) io.netty.buffer.ByteBufget(long ledgerId, long entryId) io.netty.buffer.ByteBufgetLastEntry(long ledgerId) booleanhasEntry(long ledgerId, long entryId) booleanisEmpty()booleanput(long ledgerId, long entryId, io.netty.buffer.ByteBuf entry) longsize()
-
Constructor Details
-
WriteCache
public WriteCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize) -
WriteCache
public WriteCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize, int maxSegmentSize)
-
-
Method Details
-
clear
public void clear() -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
put
public boolean put(long ledgerId, long entryId, io.netty.buffer.ByteBuf entry) -
get
public io.netty.buffer.ByteBuf get(long ledgerId, long entryId) -
hasEntry
public boolean hasEntry(long ledgerId, long entryId) -
getLastEntry
public io.netty.buffer.ByteBuf getLastEntry(long ledgerId) -
deleteLedger
public void deleteLedger(long ledgerId) -
forEach
- Throws:
IOException
-
size
public long size() -
count
public long count() -
isEmpty
public boolean isEmpty() -
align64
static int align64(int size)
-