Package org.apache.bookkeeper.bookie
Class LedgerCacheImpl
- java.lang.Object
-
- org.apache.bookkeeper.bookie.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.bookkeeper.bookie.LedgerCache
LedgerCache.LedgerIndexMetadata, LedgerCache.NoIndexForLedgerException, LedgerCache.PageEntries, LedgerCache.PageEntriesIterable
-
-
Constructor Summary
Constructors Constructor Description LedgerCacheImpl(ServerConfiguration conf, SnapshotMap<java.lang.Long,java.lang.Boolean> activeLedgers, LedgerDirsManager ledgerDirsManager)LedgerCacheImpl(ServerConfiguration conf, SnapshotMap<java.lang.Long,java.lang.Boolean> activeLedgers, LedgerDirsManager ledgerDirsManager, StatsLogger statsLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancelWaitForLastAddConfirmedUpdate(long ledgerId, Watcher<LastAddConfirmedUpdateNotification> watcher)voidclose()voiddeleteLedger(long ledgerId)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.voidflushLedger(boolean doAll)java.util.PrimitiveIterator.OfLonggetEntriesIterator(long ledgerId)longgetEntryOffset(long ledger, long entry)io.netty.buffer.ByteBufgetExplicitLac(long ledgerId)(package private) IndexInMemPageMgrgetIndexPageManager()(package private) IndexPersistenceMgrgetIndexPersistenceManager()java.lang.LonggetLastAddConfirmed(long ledgerId)longgetLastEntry(long ledgerId)intgetPageSize()booleanisFenced(long ledgerId)booleanledgerExists(long ledgerId)LedgerCache.PageEntriesIterablelistEntries(long ledgerId)voidputEntryOffset(long ledger, long entry, long offset)LedgerCache.LedgerIndexMetadatareadLedgerIndexMetadata(long ledgerId)byte[]readMasterKey(long ledgerId)voidsetExplicitLac(long ledgerId, io.netty.buffer.ByteBuf lac)booleansetFenced(long ledgerId)voidsetMasterKey(long ledgerId, byte[] masterKey)longupdateLastAddConfirmed(long ledgerId, long lac)booleanwaitForLastAddConfirmedUpdate(long ledgerId, long previousLAC, Watcher<LastAddConfirmedUpdateNotification> watcher)
-
-
-
Constructor Detail
-
LedgerCacheImpl
public LedgerCacheImpl(ServerConfiguration conf, SnapshotMap<java.lang.Long,java.lang.Boolean> activeLedgers, LedgerDirsManager ledgerDirsManager) throws java.io.IOException
- Throws:
java.io.IOException
-
LedgerCacheImpl
public LedgerCacheImpl(ServerConfiguration conf, SnapshotMap<java.lang.Long,java.lang.Boolean> activeLedgers, LedgerDirsManager ledgerDirsManager, StatsLogger statsLogger) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getIndexPersistenceManager
IndexPersistenceMgr getIndexPersistenceManager()
-
getIndexPageManager
IndexInMemPageMgr getIndexPageManager()
-
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:
getLastAddConfirmedin interfaceLedgerCache- Throws:
java.io.IOException
-
updateLastAddConfirmed
public long updateLastAddConfirmed(long ledgerId, long lac) throws java.io.IOException- Specified by:
updateLastAddConfirmedin interfaceLedgerCache- Throws:
java.io.IOException
-
waitForLastAddConfirmedUpdate
public boolean waitForLastAddConfirmedUpdate(long ledgerId, long previousLAC, Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException- Specified by:
waitForLastAddConfirmedUpdatein interfaceLedgerCache- Throws:
java.io.IOException
-
cancelWaitForLastAddConfirmedUpdate
public void cancelWaitForLastAddConfirmedUpdate(long ledgerId, Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException- Specified by:
cancelWaitForLastAddConfirmedUpdatein interfaceLedgerCache- Throws:
java.io.IOException
-
putEntryOffset
public void putEntryOffset(long ledger, long entry, long offset) throws java.io.IOException- Specified by:
putEntryOffsetin interfaceLedgerCache- Throws:
java.io.IOException
-
getEntryOffset
public long getEntryOffset(long ledger, long entry) throws java.io.IOException- Specified by:
getEntryOffsetin interfaceLedgerCache- Throws:
java.io.IOException
-
flushLedger
public void flushLedger(boolean doAll) throws java.io.IOException- Specified by:
flushLedgerin interfaceLedgerCache- Throws:
java.io.IOException
-
getLastEntry
public long getLastEntry(long ledgerId) throws java.io.IOException- Specified by:
getLastEntryin interfaceLedgerCache- Throws:
java.io.IOException
-
deleteLedger
public void deleteLedger(long ledgerId) throws java.io.IOExceptionThis 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:
deleteLedgerin interfaceLedgerCache- Throws:
java.io.IOException
-
readMasterKey
public byte[] readMasterKey(long ledgerId) throws java.io.IOException, BookieException- Specified by:
readMasterKeyin interfaceLedgerCache- Throws:
java.io.IOExceptionBookieException
-
setFenced
public boolean setFenced(long ledgerId) throws java.io.IOException- Specified by:
setFencedin interfaceLedgerCache- Throws:
java.io.IOException
-
isFenced
public boolean isFenced(long ledgerId) throws java.io.IOException- Specified by:
isFencedin interfaceLedgerCache- Throws:
java.io.IOException
-
setExplicitLac
public void setExplicitLac(long ledgerId, io.netty.buffer.ByteBuf lac) throws java.io.IOException- Specified by:
setExplicitLacin interfaceLedgerCache- Throws:
java.io.IOException
-
getExplicitLac
public io.netty.buffer.ByteBuf getExplicitLac(long ledgerId)
- Specified by:
getExplicitLacin interfaceLedgerCache
-
setMasterKey
public void setMasterKey(long ledgerId, byte[] masterKey) throws java.io.IOException- Specified by:
setMasterKeyin interfaceLedgerCache- Throws:
java.io.IOException
-
ledgerExists
public boolean ledgerExists(long ledgerId) throws java.io.IOException- Specified by:
ledgerExistsin interfaceLedgerCache- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
listEntries
public LedgerCache.PageEntriesIterable listEntries(long ledgerId) throws java.io.IOException
- Specified by:
listEntriesin interfaceLedgerCache- Throws:
java.io.IOException
-
readLedgerIndexMetadata
public LedgerCache.LedgerIndexMetadata readLedgerIndexMetadata(long ledgerId) throws java.io.IOException
- Specified by:
readLedgerIndexMetadatain interfaceLedgerCache- Throws:
java.io.IOException
-
getEntriesIterator
public java.util.PrimitiveIterator.OfLong getEntriesIterator(long ledgerId) throws java.io.IOException- Specified by:
getEntriesIteratorin interfaceLedgerCache- Throws:
java.io.IOException
-
-