Interface EntryLogger
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DefaultEntryLogger,DirectEntryLogger,ReadOnlyDefaultEntryLogger
Entry logger. Sequentially writes entries for a large number of ledgers to
a small number of log files, to avoid many random writes.
When an entry is added, a location is returned, which consists of the ID of the
log into which the entry was added, and the offset of that entry within the log.
The location is a long, with 32 bits each for the log ID and the offset. This
naturally limits the offset and thus the size of the log to Integer.MAX_VALUE.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlongaddEntry(long ledgerId, io.netty.buffer.ByteBuf buf) Add an entry for ledger ```ledgerId``` to the entrylog.voidclose()voidflush()Flush any outstanding writes to disk.default EntryLogMetadatagetEntryLogMetadata(long entryLogId) Retrieve metadata for the given entrylog ID.getEntryLogMetadata(long entryLogId, AbstractLogCompactor.Throttler throttler) Retrieve metadata for the given entrylog ID.Get the log ids for the set of logs which have been completely flushed to disk.Return a collection of all the compaction entry logs which have been compacted, but have not been cleaned up.booleanlogExists(long logId) Check whether an entrylog with the given ID exists.newCompactionLog(long logToCompact) Create a new entrylog into which compacted entries can be added.io.netty.buffer.ByteBufreadEntry(long entryLocation) Read an entry from an entrylog location.io.netty.buffer.ByteBufreadEntry(long ledgerId, long entryId, long entryLocation) Read an entry from an entrylog location, and verify that is matches the expected ledger and entry ID.booleanremoveEntryLog(long entryLogId) Delete the entrylog with the given ID.voidscanEntryLog(long entryLogId, EntryLogScanner scanner) Scan the given entrylog, returning all entries contained therein.
-
Field Details
-
UNASSIGNED_LEDGERID
static final long UNASSIGNED_LEDGERID- See Also:
-
LOG_FILE_SUFFIX
- See Also:
-
-
Method Details
-
addEntry
Add an entry for ledger ```ledgerId``` to the entrylog.- Parameters:
ledgerId- the ledger for which the entry is being addedbuf- the contents of the entry (this method does not take ownership of the refcount)- Returns:
- the location in the entry log of the added entry
- Throws:
IOException
-
readEntry
Read an entry from an entrylog location.- Parameters:
entryLocation- the location from which to read the entry- Returns:
- the entry
- Throws:
IOExceptionBookie.NoEntryException
-
readEntry
io.netty.buffer.ByteBuf readEntry(long ledgerId, long entryId, long entryLocation) throws IOException, Bookie.NoEntryException Read an entry from an entrylog location, and verify that is matches the expected ledger and entry ID.- Parameters:
ledgerId- the ledgerID to matchentryId- the entryID to matchentryLocation- the location from which to read the entry- Returns:
- the entry
- Throws:
IOExceptionBookie.NoEntryException
-
flush
Flush any outstanding writes to disk.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
newCompactionLog
Create a new entrylog into which compacted entries can be added. There is a 1-1 mapping between logs that are being compacted and the log the compacted entries are written to.- Throws:
IOException
-
incompleteCompactionLogs
Collection<CompactionEntryLog> incompleteCompactionLogs()Return a collection of all the compaction entry logs which have been compacted, but have not been cleaned up. -
getFlushedLogIds
Collection<Long> getFlushedLogIds()Get the log ids for the set of logs which have been completely flushed to disk. Only log ids in this set are considered for either compaction or garbage collection. -
scanEntryLog
Scan the given entrylog, returning all entries contained therein.- Throws:
IOException
-
getEntryLogMetadata
Retrieve metadata for the given entrylog ID. The metadata contains the size of the log, the size of the data in the log which is still active, and a list of all the ledgers contained in the log and the size of the data stored for each ledger.- Throws:
IOException
-
getEntryLogMetadata
EntryLogMetadata getEntryLogMetadata(long entryLogId, AbstractLogCompactor.Throttler throttler) throws IOException Retrieve metadata for the given entrylog ID. The metadata contains the size of the log, the size of the data in the log which is still active, and a list of all the ledgers contained in the log and the size of the data stored for each ledger.- Throws:
IOException
-
logExists
boolean logExists(long logId) Check whether an entrylog with the given ID exists. -
removeEntryLog
boolean removeEntryLog(long entryLogId) Delete the entrylog with the given ID.- Returns:
- false if the entrylog doesn't exist.
-