Class LedgerEntryImpl
java.lang.Object
org.apache.bookkeeper.client.impl.LedgerEntryImpl
- All Implemented Interfaces:
AutoCloseable,LedgerEntry
Ledger entry. Its a simple tuple containing the ledger id, the entry-id, and
the entry content.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static LedgerEntryImplcreate(long ledgerId, long entryId) static LedgerEntryImplcreate(long ledgerId, long entryId, long length, io.netty.buffer.ByteBuf buf) Returns a duplicate of this entry.static LedgerEntryImplduplicate(LedgerEntry entry) io.netty.buffer.ByteBufReturn the internalByteBufthat contains the entry payload.byte[]Returns the content of the entry as a byte array.longThe id of the entry.Exposes this entry's data as an NIOByteBuffer.longThe id of the ledger which contains the entry.longThe length of the entry, that is the size of the content expressed in bytes.voidsetEntryBuf(io.netty.buffer.ByteBuf buf) voidsetEntryId(long entryId) voidsetLength(long length)
-
Method Details
-
create
-
create
public static LedgerEntryImpl create(long ledgerId, long entryId, long length, io.netty.buffer.ByteBuf buf) -
duplicate
-
setEntryId
public void setEntryId(long entryId) -
setLength
public void setLength(long length) -
setEntryBuf
public void setEntryBuf(io.netty.buffer.ByteBuf buf) -
getLedgerId
public long getLedgerId()The id of the ledger which contains the entry.- Specified by:
getLedgerIdin interfaceLedgerEntry- Returns:
- the id of the ledger
-
getEntryId
public long getEntryId()The id of the entry.- Specified by:
getEntryIdin interfaceLedgerEntry- Returns:
- the id of the entry
-
getLength
public long getLength()The length of the entry, that is the size of the content expressed in bytes.- Specified by:
getLengthin interfaceLedgerEntry- Returns:
- the size of the content
-
getEntryBytes
public byte[] getEntryBytes()Returns the content of the entry as a byte array.- Specified by:
getEntryBytesin interfaceLedgerEntry- Returns:
- the content of the entry
-
getEntryBuffer
public io.netty.buffer.ByteBuf getEntryBuffer()Return the internalByteBufthat contains the entry payload.This call doesn't change the reference count on the returned bytebuf. If you want to use the bytebuf after the entry is released (via
LedgerEntry.close(), the caller must retain the references of the bytebuf.- Specified by:
getEntryBufferin interfaceLedgerEntry- Returns:
- a ByteBuf which contains the data
-
getEntryNioBuffer
Exposes this entry's data as an NIOByteBuffer. The returned buffer shares the content with this underneath bytebuf (which you can get it byLedgerEntry.getEntryBuffer()). Changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this underneath buffer. This method is identical toentry.getEntryBuffer().nioBuffer(). This method does not modifyreaderIndexorwriterIndexof the underlying bytebuf.- Specified by:
getEntryNioBufferin interfaceLedgerEntry
-
duplicate
Returns a duplicate of this entry.This call will retain a slice of the underneath byte buffer.
- Specified by:
duplicatein interfaceLedgerEntry- Returns:
- a duplicated ledger entry
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLedgerEntry
-