Class LedgerCacheImpl

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, LedgerCache

    public class LedgerCacheImpl
    extends java.lang.Object
    implements LedgerCache
    Implementation of LedgerCache interface. This class serves two purposes.
    • Method Detail

      • getPageSize

        public int getPageSize()
        Returns:
        page size used in ledger cache
      • getLastAddConfirmed

        public java.lang.Long getLastAddConfirmed​(long ledgerId)
                                           throws java.io.IOException
        Specified by:
        getLastAddConfirmed in interface LedgerCache
        Throws:
        java.io.IOException
      • updateLastAddConfirmed

        public long updateLastAddConfirmed​(long ledgerId,
                                           long lac)
                                    throws java.io.IOException
        Specified by:
        updateLastAddConfirmed in interface LedgerCache
        Throws:
        java.io.IOException
      • putEntryOffset

        public void putEntryOffset​(long ledger,
                                   long entry,
                                   long offset)
                            throws java.io.IOException
        Specified by:
        putEntryOffset in interface LedgerCache
        Throws:
        java.io.IOException
      • getEntryOffset

        public long getEntryOffset​(long ledger,
                                   long entry)
                            throws java.io.IOException
        Specified by:
        getEntryOffset in interface LedgerCache
        Throws:
        java.io.IOException
      • flushLedger

        public void flushLedger​(boolean doAll)
                         throws java.io.IOException
        Specified by:
        flushLedger in interface LedgerCache
        Throws:
        java.io.IOException
      • getLastEntry

        public long getLastEntry​(long ledgerId)
                          throws java.io.IOException
        Specified by:
        getLastEntry in interface LedgerCache
        Throws:
        java.io.IOException
      • deleteLedger

        public void deleteLedger​(long ledgerId)
                          throws java.io.IOException
        This method is called whenever a ledger is deleted by the BookKeeper Client and we want to remove all relevant data for it stored in the LedgerCache.
        Specified by:
        deleteLedger in interface LedgerCache
        Throws:
        java.io.IOException
      • setFenced

        public boolean setFenced​(long ledgerId)
                          throws java.io.IOException
        Specified by:
        setFenced in interface LedgerCache
        Throws:
        java.io.IOException
      • isFenced

        public boolean isFenced​(long ledgerId)
                         throws java.io.IOException
        Specified by:
        isFenced in interface LedgerCache
        Throws:
        java.io.IOException
      • setExplicitLac

        public void setExplicitLac​(long ledgerId,
                                   io.netty.buffer.ByteBuf lac)
                            throws java.io.IOException
        Specified by:
        setExplicitLac in interface LedgerCache
        Throws:
        java.io.IOException
      • getExplicitLac

        public io.netty.buffer.ByteBuf getExplicitLac​(long ledgerId)
        Specified by:
        getExplicitLac in interface LedgerCache
      • setMasterKey

        public void setMasterKey​(long ledgerId,
                                 byte[] masterKey)
                          throws java.io.IOException
        Specified by:
        setMasterKey in interface LedgerCache
        Throws:
        java.io.IOException
      • ledgerExists

        public boolean ledgerExists​(long ledgerId)
                             throws java.io.IOException
        Specified by:
        ledgerExists in interface LedgerCache
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • getEntriesIterator

        public java.util.PrimitiveIterator.OfLong getEntriesIterator​(long ledgerId)
                                                              throws java.io.IOException
        Specified by:
        getEntriesIterator in interface LedgerCache
        Throws:
        java.io.IOException