Class IndexPersistenceMgr


  • public class IndexPersistenceMgr
    extends java.lang.Object
    A IndexPersistenceMgr is responsible for managing the persistence state for the index in a bookie.
    • Constructor Detail

      • IndexPersistenceMgr

        public IndexPersistenceMgr​(int pageSize,
                                   int entriesPerPage,
                                   ServerConfiguration conf,
                                   SnapshotMap<java.lang.Long,​java.lang.Boolean> activeLedgers,
                                   LedgerDirsManager ledgerDirsManager,
                                   StatsLogger statsLogger)
                            throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getLedgerName

        public static final java.lang.String getLedgerName​(long ledgerId)
      • getFileInfo

        FileInfoBackingCache.CachedFileInfo getFileInfo​(java.lang.Long ledger,
                                                        byte[] masterKey)
                                                 throws java.io.IOException
        Get the FileInfo and increase reference count. When we get FileInfo from cache, we need to make sure it is synchronized with eviction, otherwise there might be a race condition as we get the FileInfo from cache, that FileInfo is then evicted and closed before we could even increase the reference counter.
        Throws:
        java.io.IOException
      • removeLedger

        void removeLedger​(java.lang.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.
        Throws:
        java.io.IOException
      • ledgerExists

        boolean ledgerExists​(long ledgerId)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        void close()
            throws java.io.IOException
        Throws:
        java.io.IOException
      • getLastAddConfirmed

        java.lang.Long getLastAddConfirmed​(long ledgerId)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • waitForLastAddConfirmedUpdate

        boolean waitForLastAddConfirmedUpdate​(long ledgerId,
                                              long previousLAC,
                                              Watcher<LastAddConfirmedUpdateNotification> watcher)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • cancelWaitForLastAddConfirmedUpdate

        void cancelWaitForLastAddConfirmedUpdate​(long ledgerId,
                                                 Watcher<LastAddConfirmedUpdateNotification> watcher)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • updateLastAddConfirmed

        long updateLastAddConfirmed​(long ledgerId,
                                    long lac)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • setMasterKey

        void setMasterKey​(long ledgerId,
                          byte[] masterKey)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • setFenced

        boolean setFenced​(long ledgerId)
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • isFenced

        boolean isFenced​(long ledgerId)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • setExplicitLac

        void setExplicitLac​(long ledgerId,
                            io.netty.buffer.ByteBuf lac)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getExplicitLac

        public io.netty.buffer.ByteBuf getExplicitLac​(long ledgerId)
      • getOpenFileLimit

        int getOpenFileLimit()
      • flushLedgerHeader

        void flushLedgerHeader​(long ledger)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • flushLedgerEntries

        void flushLedgerEntries​(long l,
                                java.util.List<LedgerEntryPage> entries)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • updatePage

        boolean updatePage​(LedgerEntryPage lep)
                    throws java.io.IOException
        Update the ledger entry page.
        Parameters:
        lep - ledger entry page
        Returns:
        true if it is a new page, otherwise false.
        Throws:
        java.io.IOException
      • getPersistEntryBeyondInMem

        long getPersistEntryBeyondInMem​(long ledgerId,
                                        long lastEntryInMem)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • readLedgerIndexMetadata

        public LedgerCache.LedgerIndexMetadata readLedgerIndexMetadata​(long ledgerId)
                                                                throws java.io.IOException
        Read ledger meta.
        Parameters:
        ledgerId - Ledger Id
        Throws:
        java.io.IOException