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.Closeable
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 Classes Modifier and Type Class Description static interface
WriteCache.EntryConsumer
Consumer 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 int
align64(int size)
void
clear()
void
close()
long
count()
void
deleteLedger(long ledgerId)
void
forEach(WriteCache.EntryConsumer consumer)
io.netty.buffer.ByteBuf
get(long ledgerId, long entryId)
io.netty.buffer.ByteBuf
getLastEntry(long ledgerId)
boolean
hasEntry(long ledgerId, long entryId)
boolean
isEmpty()
boolean
put(long ledgerId, long entryId, io.netty.buffer.ByteBuf entry)
long
size()
-
-
-
Method Detail
-
clear
public void clear()
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in 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)
-
-