Class LedgerHandleAdv

    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
    • Constructor Detail

      • LedgerHandleAdv

        LedgerHandleAdv​(ClientContext clientCtx,
                        long ledgerId,
                        Versioned<LedgerMetadata> metadata,
                        BookKeeper.DigestType digestType,
                        byte[] password,
                        java.util.EnumSet<WriteFlag> writeFlags)
                 throws java.security.GeneralSecurityException,
                        java.lang.NumberFormatException
        Throws:
        java.security.GeneralSecurityException
        java.lang.NumberFormatException
    • Method Detail

      • addEntry

        public long addEntry​(long entryId,
                             byte[] data)
                      throws java.lang.InterruptedException,
                             BKException
        Add entry synchronously to an open ledger.
        Overrides:
        addEntry in class LedgerHandle
        Parameters:
        entryId - entryId of the entry to add
        data - array of bytes to be written to the ledger do not reuse the buffer, bk-client will release it appropriately
        Returns:
        entryId that is just created.
        Throws:
        java.lang.InterruptedException
        BKException
      • addEntry

        public long addEntry​(long entryId,
                             byte[] data,
                             int offset,
                             int length)
                      throws java.lang.InterruptedException,
                             BKException
        Add entry synchronously to an open ledger.
        Overrides:
        addEntry in class LedgerHandle
        Parameters:
        entryId - entryId of the entry to add
        data - array of bytes to be written to the ledger do not reuse the buffer, bk-client will release it appropriately
        offset - offset from which to take bytes from data
        length - number of bytes to take from data
        Returns:
        The entryId of newly inserted entry.
        Throws:
        java.lang.InterruptedException
        BKException
      • asyncAddEntry

        public void asyncAddEntry​(long entryId,
                                  byte[] data,
                                  AsyncCallback.AddCallback cb,
                                  java.lang.Object ctx)
        Add entry asynchronously to an open ledger.
        Overrides:
        asyncAddEntry in class LedgerHandle
        Parameters:
        entryId - entryId of the entry to add
        data - array of bytes to be written do not reuse the buffer, bk-client will release it appropriately
        cb - object implementing callbackinterface
        ctx - some control object
      • asyncAddEntry

        public void asyncAddEntry​(long entryId,
                                  byte[] data,
                                  int offset,
                                  int length,
                                  AsyncCallback.AddCallback cb,
                                  java.lang.Object ctx)
        Add entry asynchronously to an open ledger, using an offset and range.
        Overrides:
        asyncAddEntry in class LedgerHandle
        Parameters:
        entryId - entryId of the entry to add
        data - array of bytes to be written do not reuse the buffer, bk-client will release it appropriately
        offset - offset from which to take bytes from data
        length - number of bytes to take from data
        cb - object implementing callbackinterface
        ctx - some control object
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if offset or length is negative or offset and length sum to a value higher than the length of data.
      • asyncAddEntry

        public void asyncAddEntry​(long entryId,
                                  byte[] data,
                                  int offset,
                                  int length,
                                  AsyncCallback.AddCallbackWithLatency cb,
                                  java.lang.Object ctx)
        Add entry asynchronously to an open ledger, using an offset and range.
        Overrides:
        asyncAddEntry in class LedgerHandle
        Parameters:
        entryId - entryId of the entry to add
        data - array of bytes to be written do not reuse the buffer, bk-client will release it appropriately
        offset - offset from which to take bytes from data
        length - number of bytes to take from data
        cb - object implementing callbackinterface
        ctx - some control object
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if offset or length is negative or offset and length sum to a value higher than the length of data.
      • doAsyncAddEntry

        protected void doAsyncAddEntry​(PendingAddOp op)
        Overriding part is mostly around setting entryId. Though there may be some code duplication, Choose to have the override routine so the control flow is unaltered in the base class.
        Overrides:
        doAsyncAddEntry in class LedgerHandle
      • writeAsync

        public java.util.concurrent.CompletableFuture<java.lang.Long> writeAsync​(long entryId,
                                                                                 io.netty.buffer.ByteBuf data)
        Description copied from interface: WriteAdvHandle
        Add entry asynchronously to an open ledger.
        Specified by:
        writeAsync in interface WriteAdvHandle
        Parameters:
        entryId - entryId to be added
        data - array of bytes to be written do not reuse the buffer, bk-client will release it appropriately.
        Returns:
        an handle to the result, in case of success it will return the same value of param entryId
      • asyncAddEntry

        public void asyncAddEntry​(io.netty.buffer.ByteBuf data,
                                  AsyncCallback.AddCallback cb,
                                  java.lang.Object ctx)
        LedgerHandleAdv will not allow addEntry without providing an entryId.
        Overrides:
        asyncAddEntry in class LedgerHandle
      • asyncAddEntry

        public void asyncAddEntry​(byte[] data,
                                  int offset,
                                  int length,
                                  AsyncCallback.AddCallback cb,
                                  java.lang.Object ctx)
        LedgerHandleAdv will not allow addEntry without providing an entryId.
        Overrides:
        asyncAddEntry in class LedgerHandle
        Parameters:
        data - array of bytes to be written do not reuse the buffer, bk-client will release it appropriately
        offset - offset from which to take bytes from data
        length - number of bytes to take from data
        cb - object implementing callbackinterface
        ctx - some control object