Package org.apache.bookkeeper.bookie
Class IndexPersistenceMgr
- java.lang.Object
-
- org.apache.bookkeeper.bookie.IndexPersistenceMgr
-
public class IndexPersistenceMgr extends java.lang.Object
AIndexPersistenceMgr
is 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) int
entriesPerPage
(package private) FileInfoBackingCache
fileInfoBackingCache
(package private) LedgerDirsManager
ledgerDirsManager
(package private) int
openFileLimit
(package private) int
pageSize
(package private) com.google.common.cache.Cache<java.lang.Long,FileInfoBackingCache.CachedFileInfo>
readFileInfoCache
(package private) static java.lang.String
RLOC
(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) void
cancelWaitForLastAddConfirmedUpdate(long ledgerId, Watcher<LastAddConfirmedUpdateNotification> watcher)
(package private) void
close()
(package private) void
flushLedgerEntries(long l, java.util.List<LedgerEntryPage> entries)
(package private) void
flushLedgerHeader(long ledger)
io.netty.buffer.ByteBuf
getExplicitLac(long ledgerId)
(package private) FileInfoBackingCache.CachedFileInfo
getFileInfo(java.lang.Long ledger, byte[] masterKey)
Get the FileInfo and increase reference count.(package private) java.lang.Long
getLastAddConfirmed(long ledgerId)
static java.lang.String
getLedgerName(long ledgerId)
(package private) int
getOpenFileLimit()
(package private) long
getPersistEntryBeyondInMem(long ledgerId, long lastEntryInMem)
(package private) boolean
isFenced(long ledgerId)
(package private) boolean
ledgerExists(long ledgerId)
LedgerCache.LedgerIndexMetadata
readLedgerIndexMetadata(long ledgerId)
Read ledger meta.(package private) byte[]
readMasterKey(long ledgerId)
(package private) void
removeLedger(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) void
setExplicitLac(long ledgerId, io.netty.buffer.ByteBuf lac)
(package private) boolean
setFenced(long ledgerId)
(package private) void
setMasterKey(long ledgerId, byte[] masterKey)
(package private) long
updateLastAddConfirmed(long ledgerId, long lac)
(package private) boolean
updatePage(LedgerEntryPage lep)
Update the ledger entry page.(package private) boolean
waitForLastAddConfirmedUpdate(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.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
-
readMasterKey
byte[] readMasterKey(long ledgerId) throws java.io.IOException, BookieException
- Throws:
java.io.IOException
BookieException
-
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
-
-