Class WriteCache
- java.lang.Object
-
- org.apache.bookkeeper.bookie.storage.ldb.WriteCache
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class WriteCache extends java.lang.Object implements java.io.CloseableWrite 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 Classes Modifier and Type Class Description static interfaceWriteCache.EntryConsumerConsumer that is used to scan the entire write cache.
-
Constructor Summary
Constructors Constructor Description WriteCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize)WriteCache(io.netty.buffer.ByteBufAllocator allocator, long maxCacheSize, int maxSegmentSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (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()
-
-
-
Method Detail
-
clear
public void clear()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
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
public void forEach(WriteCache.EntryConsumer consumer) throws java.io.IOException
- Throws:
java.io.IOException
-
size
public long size()
-
count
public long count()
-
isEmpty
public boolean isEmpty()
-
align64
static int align64(int size)
-
-