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) LedgerStorage
ledgerStorage
(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) long
addEntry(io.netty.buffer.ByteBuf entry)
(package private) void
cancelWaitForLastAddConfirmedUpdate(Watcher<LastAddConfirmedUpdateNotification> watcher)
(package private) void
checkAccess(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.ByteBuf
getExplicitLac()
(package private) long
getLastAddConfirmed()
long
getLedgerId()
(package private) java.util.PrimitiveIterator.OfLong
getListOfEntriesOfLedger(long ledgerId)
(package private) boolean
isFenced()
(package private) io.netty.buffer.ByteBuf
readEntry(long entryId)
(package private) void
setExplicitLac(io.netty.buffer.ByteBuf lac)
(package private) boolean
setFenced()
(package private) boolean
waitForLastAddConfirmedUpdate(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:
checkAccess
in classLedgerDescriptor
- Throws:
BookieException
java.io.IOException
-
getLedgerId
public long getLedgerId()
- Specified by:
getLedgerId
in classLedgerDescriptor
-
setFenced
boolean setFenced() throws java.io.IOException
- Specified by:
setFenced
in classLedgerDescriptor
- Throws:
java.io.IOException
-
isFenced
boolean isFenced() throws java.io.IOException, BookieException
- Specified by:
isFenced
in classLedgerDescriptor
- Throws:
java.io.IOException
BookieException
-
setExplicitLac
void setExplicitLac(io.netty.buffer.ByteBuf lac) throws java.io.IOException
- Specified by:
setExplicitLac
in classLedgerDescriptor
- Throws:
java.io.IOException
-
getExplicitLac
io.netty.buffer.ByteBuf getExplicitLac() throws java.io.IOException, BookieException
- Specified by:
getExplicitLac
in classLedgerDescriptor
- Throws:
java.io.IOException
BookieException
-
fenceAndLogInJournal
java.util.concurrent.CompletableFuture<java.lang.Boolean> fenceAndLogInJournal(Journal journal) throws java.io.IOException
Description copied from class:LedgerDescriptor
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.We should satisfy the future only after we complete logging fence entry in Journal
- Specified by:
fenceAndLogInJournal
in classLedgerDescriptor
- Returns:
- Throws:
java.io.IOException
-
addEntry
long addEntry(io.netty.buffer.ByteBuf entry) throws java.io.IOException, BookieException
- Specified by:
addEntry
in classLedgerDescriptor
- Throws:
java.io.IOException
BookieException
-
readEntry
io.netty.buffer.ByteBuf readEntry(long entryId) throws java.io.IOException, BookieException
- Specified by:
readEntry
in classLedgerDescriptor
- Throws:
java.io.IOException
BookieException
-
getLastAddConfirmed
long getLastAddConfirmed() throws java.io.IOException, BookieException
- Specified by:
getLastAddConfirmed
in classLedgerDescriptor
- Throws:
java.io.IOException
BookieException
-
waitForLastAddConfirmedUpdate
boolean waitForLastAddConfirmedUpdate(long previousLAC, Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException
- Specified by:
waitForLastAddConfirmedUpdate
in classLedgerDescriptor
- Throws:
java.io.IOException
-
cancelWaitForLastAddConfirmedUpdate
void cancelWaitForLastAddConfirmedUpdate(Watcher<LastAddConfirmedUpdateNotification> watcher) throws java.io.IOException
- Specified by:
cancelWaitForLastAddConfirmedUpdate
in classLedgerDescriptor
- Throws:
java.io.IOException
-
getListOfEntriesOfLedger
java.util.PrimitiveIterator.OfLong getListOfEntriesOfLedger(long ledgerId) throws java.io.IOException
- Specified by:
getListOfEntriesOfLedger
in classLedgerDescriptor
- Throws:
java.io.IOException
-
-