Class DirectEntryLogger
java.lang.Object
org.apache.bookkeeper.bookie.storage.directentrylogger.DirectEntryLogger
- All Implemented Interfaces:
AutoCloseable,EntryLogger
DirectEntryLogger.
-
Field Summary
Fields inherited from interface org.apache.bookkeeper.bookie.storage.EntryLogger
LOG_FILE_SUFFIX, UNASSIGNED_LEDGERID -
Constructor Summary
ConstructorsConstructorDescriptionDirectEntryLogger(File ledgerDir, EntryLogIds ids, NativeIO nativeIO, io.netty.buffer.ByteBufAllocator allocator, ExecutorService writeExecutor, ExecutorService flushExecutor, long maxFileSize, int maxSaneEntrySize, long totalWriteBufferSize, long totalReadBufferSize, int readBufferSize, int numReadThreads, int maxFdCacheTimeSeconds, Slogger slogParent, StatsLogger stats) -
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.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.static Filestatic StringlogFilename(File directory, int logId) newCompactionLog(long srcLogId) Create a new entrylog into which compacted entries can be added.(package private) LogReadernewDirectReader(int logId) 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.(package private) EntryLogMetadatareadEntryLogIndex(long logId) booleanremoveEntryLog(long entryLogId) Delete the entrylog with the given ID.voidscanEntryLog(long entryLogId, EntryLogScanner scanner) Scan the given entrylog, returning all entries contained therein.(package private) EntryLogMetadatascanEntryLogMetadata(long logId, AbstractLogCompactor.Throttler throttler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.bookkeeper.bookie.storage.EntryLogger
getEntryLogMetadata
-
Constructor Details
-
DirectEntryLogger
public DirectEntryLogger(File ledgerDir, EntryLogIds ids, NativeIO nativeIO, io.netty.buffer.ByteBufAllocator allocator, ExecutorService writeExecutor, ExecutorService flushExecutor, long maxFileSize, int maxSaneEntrySize, long totalWriteBufferSize, long totalReadBufferSize, int readBufferSize, int numReadThreads, int maxFdCacheTimeSeconds, Slogger slogParent, StatsLogger stats) throws IOException - Throws:
IOException
-
-
Method Details
-
addEntry
Description copied from interface:EntryLoggerAdd an entry for ledger ```ledgerId``` to the entrylog.- Specified by:
addEntryin interfaceEntryLogger- 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
public io.netty.buffer.ByteBuf readEntry(long entryLocation) throws IOException, Bookie.NoEntryException Description copied from interface:EntryLoggerRead an entry from an entrylog location.- Specified by:
readEntryin interfaceEntryLogger- Parameters:
entryLocation- the location from which to read the entry- Returns:
- the entry
- Throws:
IOExceptionBookie.NoEntryException
-
readEntry
public io.netty.buffer.ByteBuf readEntry(long ledgerId, long entryId, long entryLocation) throws IOException, Bookie.NoEntryException Description copied from interface:EntryLoggerRead an entry from an entrylog location, and verify that is matches the expected ledger and entry ID.- Specified by:
readEntryin interfaceEntryLogger- 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
Description copied from interface:EntryLoggerFlush any outstanding writes to disk.- Specified by:
flushin interfaceEntryLogger- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEntryLogger- Throws:
IOException
-
getFlushedLogIds
Description copied from interface:EntryLoggerGet 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.- Specified by:
getFlushedLogIdsin interfaceEntryLogger
-
removeEntryLog
public boolean removeEntryLog(long entryLogId) Description copied from interface:EntryLoggerDelete the entrylog with the given ID.- Specified by:
removeEntryLogin interfaceEntryLogger- Returns:
- false if the entrylog doesn't exist.
-
scanEntryLog
Description copied from interface:EntryLoggerScan the given entrylog, returning all entries contained therein.- Specified by:
scanEntryLogin interfaceEntryLogger- Throws:
IOException
-
logExists
public boolean logExists(long logId) Description copied from interface:EntryLoggerCheck whether an entrylog with the given ID exists.- Specified by:
logExistsin interfaceEntryLogger
-
getEntryLogMetadata
public EntryLogMetadata getEntryLogMetadata(long entryLogId, AbstractLogCompactor.Throttler throttler) throws IOException Description copied from interface:EntryLoggerRetrieve 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.- Specified by:
getEntryLogMetadatain interfaceEntryLogger- Throws:
IOException
-
readEntryLogIndex
- Throws:
IOException
-
scanEntryLogMetadata
EntryLogMetadata scanEntryLogMetadata(long logId, AbstractLogCompactor.Throttler throttler) throws IOException - Throws:
IOException
-
newDirectReader
- Throws:
IOException
-
logFile
-
logFilename
-
newCompactionLog
Description copied from interface:EntryLoggerCreate 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.- Specified by:
newCompactionLogin interfaceEntryLogger- Throws:
IOException
-
incompleteCompactionLogs
Description copied from interface:EntryLoggerReturn a collection of all the compaction entry logs which have been compacted, but have not been cleaned up.- Specified by:
incompleteCompactionLogsin interfaceEntryLogger
-