Package org.apache.bookkeeper.bookie
Class IndexPersistenceMgr
- java.lang.Object
-
- org.apache.bookkeeper.bookie.IndexPersistenceMgr
-
public class IndexPersistenceMgr extends java.lang.ObjectAIndexPersistenceMgris responsible for managing the persistence state for the index in a bookie.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) SnapshotMap<java.lang.Long,java.lang.Boolean>activeLedgers(package private) intentriesPerPage(package private) FileInfoBackingCachefileInfoBackingCache(package private) LedgerDirsManagerledgerDirsManager(package private) intopenFileLimit(package private) intpageSize(package private) com.google.common.cache.Cache<java.lang.Long,FileInfoBackingCache.CachedFileInfo>readFileInfoCache(package private) static java.lang.StringRLOC(package private) com.google.common.cache.Cache<java.lang.Long,FileInfoBackingCache.CachedFileInfo>writeFileInfoCache
-
Constructor Summary
Constructors Constructor Description IndexPersistenceMgr(int pageSize, int entriesPerPage, ServerConfiguration conf, SnapshotMap<java.lang.Long,java.lang.Boolean> activeLedgers, LedgerDirsManager ledgerDirsManager, StatsLogger statsLogger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcancelWaitForLastAddConfirmedUpdate(long ledgerId, Watcher<LastAddConfirmedUpdateNotification> watcher)(package private) voidclose()(package private) voidflushLedgerEntries(long l, java.util.List<LedgerEntryPage> entries)(package private) voidflushLedgerHeader(long ledger)io.netty.buffer.ByteBufgetExplicitLac(long ledgerId)(package private) FileInfoBackingCache.CachedFileInfogetFileInfo(java.lang.Long ledger, byte[] masterKey)Get the FileInfo and increase reference count.(package private) java.lang.LonggetLastAddConfirmed(long ledgerId)static java.lang.StringgetLedgerName(long ledgerId)(package private) intgetOpenFileLimit()(package private) longgetPersistEntryBeyondInMem(long ledgerId, long lastEntryInMem)(package private) booleanisFenced(long ledgerId)(package private) booleanledgerExists(long ledgerId)LedgerCache.LedgerIndexMetadatareadLedgerIndexMetadata(long ledgerId)Read ledger meta.(package private) byte[]readMasterKey(long ledgerId)(package private) voidremoveLedger(java.lang.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.(package private) voidsetExplicitLac(long ledgerId, io.netty.buffer.ByteBuf lac)(package private) booleansetFenced(long ledgerId)(package private) voidsetMasterKey(long ledgerId, byte[] masterKey)(package private) longupdateLastAddConfirmed(long ledgerId, long lac)(package private) booleanupdatePage(LedgerEntryPage lep)Update the ledger entry page.(package private) booleanwaitForLastAddConfirmedUpdate(long ledgerId, long previousLAC, Watcher<LastAddConfirmedUpdateNotification> watcher)
-
-
-
Field Detail
-
RLOC
static final java.lang.String RLOC
- See Also:
- Constant Field Values
-
writeFileInfoCache
final com.google.common.cache.Cache<java.lang.Long,FileInfoBackingCache.CachedFileInfo> writeFileInfoCache
-
readFileInfoCache
final com.google.common.cache.Cache<java.lang.Long,FileInfoBackingCache.CachedFileInfo> readFileInfoCache
-
fileInfoBackingCache
final FileInfoBackingCache fileInfoBackingCache
-
openFileLimit
final int openFileLimit
-
pageSize
final int pageSize
-
entriesPerPage
final int entriesPerPage
-
activeLedgers
final SnapshotMap<java.lang.Long,java.lang.Boolean> activeLedgers
-
ledgerDirsManager
final LedgerDirsManager ledgerDirsManager
-
-
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.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.- 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
-
readMasterKey
byte[] readMasterKey(long ledgerId) throws java.io.IOException, BookieException- Throws:
java.io.IOExceptionBookieException
-
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
-
-