Class LedgerEntryImpl

java.lang.Object
org.apache.bookkeeper.client.impl.LedgerEntryImpl
All Implemented Interfaces:
AutoCloseable, LedgerEntry

public class LedgerEntryImpl extends Object implements LedgerEntry
Ledger entry. Its a simple tuple containing the ledger id, the entry-id, and the entry content.
  • Method Details

    • 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 interface LedgerEntry
      Returns:
      the id of the ledger
    • getEntryId

      public long getEntryId()
      The id of the entry.
      Specified by:
      getEntryId in interface LedgerEntry
      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 interface LedgerEntry
      Returns:
      the size of the content
    • getEntryBytes

      public byte[] getEntryBytes()
      Returns the content of the entry as a byte array.
      Specified by:
      getEntryBytes in interface LedgerEntry
      Returns:
      the content of the entry
    • getEntryBuffer

      public io.netty.buffer.ByteBuf getEntryBuffer()
      Return the internal ByteBuf 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 interface LedgerEntry
      Returns:
      a ByteBuf which contains the data
    • getEntryNioBuffer

      public ByteBuffer getEntryNioBuffer()
      Exposes this entry's data as an NIO ByteBuffer. The returned buffer shares the content with this underneath bytebuf (which you can get it by LedgerEntry.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 to entry.getEntryBuffer().nioBuffer(). This method does not modify readerIndex or writerIndex of the underlying bytebuf.
      Specified by:
      getEntryNioBuffer in interface LedgerEntry
    • 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 interface LedgerEntry
      Returns:
      a duplicated ledger entry
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface LedgerEntry