Package org.apache.bookkeeper.bookie
Class LedgerDescriptorImpl
- java.lang.Object
-
- org.apache.bookkeeper.bookie.LedgerDescriptor
-
- org.apache.bookkeeper.bookie.LedgerDescriptorImpl
-
- Direct Known Subclasses:
LedgerDescriptorReadOnlyImpl
public class LedgerDescriptorImpl extends LedgerDescriptor
Implements a ledger inside a bookie. In particular, it implements operations to write entries to a ledger and read entries from a ledger.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) LedgerStorageledgerStorage(package private) byte[]masterKey
-
Constructor Summary
Constructors Constructor Description LedgerDescriptorImpl(byte[] masterKey, long ledgerId, LedgerStorage ledgerStorage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) longaddEntry(io.netty.buffer.ByteBuf entry)(package private) voidcancelWaitForLastAddConfirmedUpdate(Watcher<LastAddConfirmedUpdateNotification> watcher)(package private) voidcheckAccess(byte[] masterKey)(package private) java.util.concurrent.CompletableFuture<java.lang.Boolean>fenceAndLogInJournal(Journal journal)When we fence a ledger, we need to first set ledger to fenced state in memory and then log the fence entry in Journal so that we can rebuild the state.(package private) io.netty.buffer.ByteBufgetExplicitLac()(package private) longgetLastAddConfirmed()longgetLedgerId()(package private) java.util.PrimitiveIterator.OfLonggetListOfEntriesOfLedger(long ledgerId)(package private) booleanisFenced()(package private) io.netty.buffer.ByteBufreadEntry(long entryId)(package private) voidsetExplicitLac(io.netty.buffer.ByteBuf lac)(package private) booleansetFenced()(package private) booleanwaitForLastAddConfirmedUpdate(long previousLAC, Watcher<LastAddConfirmedUpdateNotification> watcher)-
Methods inherited from class org.apache.bookkeeper.bookie.LedgerDescriptor
create, createLedgerFenceEntry, createReadOnly
-
-
-
-
Field Detail
-
ledgerStorage
final LedgerStorage ledgerStorage
-
masterKey
final byte[] masterKey
-
-
Constructor Detail
-
LedgerDescriptorImpl
LedgerDescriptorImpl(byte[] masterKey, long ledgerId, LedgerStorage ledgerStorage)
-
-
Method Detail
-
checkAccess
void checkAccess(byte[] masterKey) throws BookieException, java.io.IOException- Specified by:
checkAccessin classLedgerDescriptor- Throws:
BookieExceptionjava.io.IOException
-
getLedgerId
public long getLedgerId()
- Specified by:
getLedgerIdin classLedgerDescriptor
-
setFenced
boolean setFenced() throws java.io.IOException- Specified by:
setFencedin classLedgerDescriptor- Throws:
java.io.IOException
-
isFenced
boolean isFenced() throws java.io.IOException, BookieException- Specified by:
isFencedin classLedgerDescriptor- Throws:
java.io.IOExceptionBookieException
-
setExplicitLac
void setExplicitLac(io.netty.buffer.ByteBuf lac) throws java.io.IOException- Specified by:
setExplicitLacin classLedgerDescriptor- Throws:
java.io.IOException
-
getExplicitLac
io.netty.buffer.ByteBuf getExplicitLac() throws java.io.IOException, BookieException- Specified by:
getExplicitLacin classLedgerDescriptor- Throws:
java.io.IOExceptionBookieException
-
fenceAndLogInJournal
java.util.concurrent.CompletableFuture<java.lang.Boolean> fenceAndLogInJournal(Journal journal) throws java.io.IOException
Description copied from class:LedgerDescriptorWhen we fence a ledger, we need to first set ledger to fenced state in memory and then log the fence entry in Journal so that we can rebuild the state.We should satisfy the future only after we complete logging fence entry in Journal
- Specified by:
fenceAndLogInJournalin classLedgerDescriptor- Returns:
- Throws:
java.io.IOException
-
addEntry
long addEntry(io.netty.buffer.ByteBuf entry) throws java.io.IOException, BookieException- Specified by:
addEntryin classLedgerDescriptor- Throws:
java.io.IOExceptionBookieException
-
readEntry
io.netty.buffer.ByteBuf readEntry(long entryId) throws java.io.IOException, BookieException- Specified by:
readEntryin classLedgerDescriptor- Throws:
java.io.IOExceptionBookieException
-
getLastAddConfirmed
long getLastAddConfirmed() throws java.io.IOException, BookieException- Specified by:
getLastAddConfirmedin classLedgerDescriptor- Throws:
java.io.IOExceptionBookieException
-
waitForLastAddConfirmedUpdate
boolean waitForLastAddConfirmedUpdate(long previousLAC, Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException- Specified by:
waitForLastAddConfirmedUpdatein classLedgerDescriptor- Throws:
java.io.IOException
-
cancelWaitForLastAddConfirmedUpdate
void cancelWaitForLastAddConfirmedUpdate(Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException
- Specified by:
cancelWaitForLastAddConfirmedUpdatein classLedgerDescriptor- Throws:
java.io.IOException
-
getListOfEntriesOfLedger
java.util.PrimitiveIterator.OfLong getListOfEntriesOfLedger(long ledgerId) throws java.io.IOException- Specified by:
getListOfEntriesOfLedgerin classLedgerDescriptor- Throws:
java.io.IOException
-
-