Class LedgerEntryImpl
- java.lang.Object
-
- org.apache.bookkeeper.client.impl.LedgerEntryImpl
-
- All Implemented Interfaces:
java.lang.AutoCloseable,LedgerEntry
public class LedgerEntryImpl extends java.lang.Object implements LedgerEntry
Ledger entry. Its a simple tuple containing the ledger id, the entry-id, and the entry content.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static LedgerEntryImplcreate(long ledgerId, long entryId)static LedgerEntryImplcreate(long ledgerId, long entryId, long length, io.netty.buffer.ByteBuf buf)LedgerEntryImplduplicate()Returns a duplicate of this entry.static LedgerEntryImplduplicate(LedgerEntry entry)io.netty.buffer.ByteBufgetEntryBuffer()Return the internalByteBufthat contains the entry payload.byte[]getEntryBytes()Returns the content of the entry as a byte array.longgetEntryId()The id of the entry.java.nio.ByteBuffergetEntryNioBuffer()Exposes this entry's data as an NIOByteBuffer.longgetLedgerId()The id of the ledger which contains the entry.longgetLength()The 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 Detail
-
create
public static LedgerEntryImpl create(long ledgerId, long entryId)
-
create
public static LedgerEntryImpl create(long ledgerId, long entryId, long length, io.netty.buffer.ByteBuf buf)
-
duplicate
public static LedgerEntryImpl duplicate(LedgerEntry entry)
-
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
public java.nio.ByteBuffer 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
public LedgerEntryImpl 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 interfacejava.lang.AutoCloseable- Specified by:
closein interfaceLedgerEntry
-
-