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 void
cancelWaitForLastAddConfirmedUpdate(long ledgerId, Watcher<LastAddConfirmedUpdateNotification> watcher)
void
close()
void
deleteLedger(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.void
flushLedger(boolean doAll)
java.util.PrimitiveIterator.OfLong
getEntriesIterator(long ledgerId)
long
getEntryOffset(long ledger, long entry)
io.netty.buffer.ByteBuf
getExplicitLac(long ledgerId)
(package private) IndexInMemPageMgr
getIndexPageManager()
(package private) IndexPersistenceMgr
getIndexPersistenceManager()
java.lang.Long
getLastAddConfirmed(long ledgerId)
long
getLastEntry(long ledgerId)
int
getPageSize()
boolean
isFenced(long ledgerId)
boolean
ledgerExists(long ledgerId)
LedgerCache.PageEntriesIterable
listEntries(long ledgerId)
void
putEntryOffset(long ledger, long entry, long offset)
LedgerCache.LedgerIndexMetadata
readLedgerIndexMetadata(long ledgerId)
byte[]
readMasterKey(long ledgerId)
void
setExplicitLac(long ledgerId, io.netty.buffer.ByteBuf lac)
boolean
setFenced(long ledgerId)
void
setMasterKey(long ledgerId, byte[] masterKey)
long
updateLastAddConfirmed(long ledgerId, long lac)
boolean
waitForLastAddConfirmedUpdate(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:
getLastAddConfirmed
in interfaceLedgerCache
- Throws:
java.io.IOException
-
updateLastAddConfirmed
public long updateLastAddConfirmed(long ledgerId, long lac) throws java.io.IOException
- Specified by:
updateLastAddConfirmed
in interfaceLedgerCache
- Throws:
java.io.IOException
-
waitForLastAddConfirmedUpdate
public boolean waitForLastAddConfirmedUpdate(long ledgerId, long previousLAC, Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException
- Specified by:
waitForLastAddConfirmedUpdate
in interfaceLedgerCache
- Throws:
java.io.IOException
-
cancelWaitForLastAddConfirmedUpdate
public void cancelWaitForLastAddConfirmedUpdate(long ledgerId, Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException
- Specified by:
cancelWaitForLastAddConfirmedUpdate
in interfaceLedgerCache
- Throws:
java.io.IOException
-
putEntryOffset
public void putEntryOffset(long ledger, long entry, long offset) throws java.io.IOException
- Specified by:
putEntryOffset
in interfaceLedgerCache
- Throws:
java.io.IOException
-
getEntryOffset
public long getEntryOffset(long ledger, long entry) throws java.io.IOException
- Specified by:
getEntryOffset
in interfaceLedgerCache
- Throws:
java.io.IOException
-
flushLedger
public void flushLedger(boolean doAll) throws java.io.IOException
- Specified by:
flushLedger
in interfaceLedgerCache
- Throws:
java.io.IOException
-
getLastEntry
public long getLastEntry(long ledgerId) throws java.io.IOException
- Specified by:
getLastEntry
in interfaceLedgerCache
- 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 interfaceLedgerCache
- Throws:
java.io.IOException
-
readMasterKey
public byte[] readMasterKey(long ledgerId) throws java.io.IOException, BookieException
- Specified by:
readMasterKey
in interfaceLedgerCache
- Throws:
java.io.IOException
BookieException
-
setFenced
public boolean setFenced(long ledgerId) throws java.io.IOException
- Specified by:
setFenced
in interfaceLedgerCache
- Throws:
java.io.IOException
-
isFenced
public boolean isFenced(long ledgerId) throws java.io.IOException
- Specified by:
isFenced
in interfaceLedgerCache
- Throws:
java.io.IOException
-
setExplicitLac
public void setExplicitLac(long ledgerId, io.netty.buffer.ByteBuf lac) throws java.io.IOException
- Specified by:
setExplicitLac
in interfaceLedgerCache
- Throws:
java.io.IOException
-
getExplicitLac
public io.netty.buffer.ByteBuf getExplicitLac(long ledgerId)
- Specified by:
getExplicitLac
in interfaceLedgerCache
-
setMasterKey
public void setMasterKey(long ledgerId, byte[] masterKey) throws java.io.IOException
- Specified by:
setMasterKey
in interfaceLedgerCache
- Throws:
java.io.IOException
-
ledgerExists
public boolean ledgerExists(long ledgerId) throws java.io.IOException
- Specified by:
ledgerExists
in interfaceLedgerCache
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
listEntries
public LedgerCache.PageEntriesIterable listEntries(long ledgerId) throws java.io.IOException
- Specified by:
listEntries
in interfaceLedgerCache
- Throws:
java.io.IOException
-
readLedgerIndexMetadata
public LedgerCache.LedgerIndexMetadata readLedgerIndexMetadata(long ledgerId) throws java.io.IOException
- Specified by:
readLedgerIndexMetadata
in interfaceLedgerCache
- Throws:
java.io.IOException
-
getEntriesIterator
public java.util.PrimitiveIterator.OfLong getEntriesIterator(long ledgerId) throws java.io.IOException
- Specified by:
getEntriesIterator
in interfaceLedgerCache
- Throws:
java.io.IOException
-
-