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 void
close()
static LedgerEntryImpl
create(long ledgerId, long entryId)
static LedgerEntryImpl
create(long ledgerId, long entryId, long length, io.netty.buffer.ByteBuf buf)
LedgerEntryImpl
duplicate()
Returns a duplicate of this entry.static LedgerEntryImpl
duplicate(LedgerEntry entry)
io.netty.buffer.ByteBuf
getEntryBuffer()
Return the internalByteBuf
that contains the entry payload.byte[]
getEntryBytes()
Returns the content of the entry as a byte array.long
getEntryId()
The id of the entry.java.nio.ByteBuffer
getEntryNioBuffer()
Exposes this entry's data as an NIOByteBuffer
.long
getLedgerId()
The id of the ledger which contains the entry.long
getLength()
The length of the entry, that is the size of the content expressed in bytes.void
setEntryBuf(io.netty.buffer.ByteBuf buf)
void
setEntryId(long entryId)
void
setLength(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:
getLedgerId
in interfaceLedgerEntry
- Returns:
- the id of the ledger
-
getEntryId
public long getEntryId()
The id of the entry.- Specified by:
getEntryId
in 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:
getLength
in interfaceLedgerEntry
- Returns:
- the size of the content
-
getEntryBytes
public byte[] getEntryBytes()
Returns the content of the entry as a byte array.- Specified by:
getEntryBytes
in interfaceLedgerEntry
- Returns:
- the content of the entry
-
getEntryBuffer
public io.netty.buffer.ByteBuf getEntryBuffer()
Return the internalByteBuf
that 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:
getEntryBuffer
in 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 modifyreaderIndex
orwriterIndex
of the underlying bytebuf.- Specified by:
getEntryNioBuffer
in interfaceLedgerEntry
-
duplicate
public LedgerEntryImpl duplicate()
Returns a duplicate of this entry.This call will retain a slice of the underneath byte buffer.
- Specified by:
duplicate
in interfaceLedgerEntry
- Returns:
- a duplicated ledger entry
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceLedgerEntry
-
-