Class DirectEntryLogger
- java.lang.Object
-
- org.apache.bookkeeper.bookie.storage.directentrylogger.DirectEntryLogger
-
- All Implemented Interfaces:
java.lang.AutoCloseable,EntryLogger
public class DirectEntryLogger extends java.lang.Object implements EntryLogger
DirectEntryLogger.
-
-
Field Summary
-
Fields inherited from interface org.apache.bookkeeper.bookie.storage.EntryLogger
LOG_FILE_SUFFIX, UNASSIGNED_LEDGERID
-
-
Constructor Summary
Constructors Constructor Description DirectEntryLogger(java.io.File ledgerDir, EntryLogIds ids, NativeIO nativeIO, io.netty.buffer.ByteBufAllocator allocator, java.util.concurrent.ExecutorService writeExecutor, java.util.concurrent.ExecutorService flushExecutor, long maxFileSize, int maxSaneEntrySize, long totalWriteBufferSize, long totalReadBufferSize, int readBufferSize, int numReadThreads, int maxFdCacheTimeSeconds, Slogger slogParent, StatsLogger stats)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddEntry(long ledgerId, io.netty.buffer.ByteBuf buf)Add an entry for ledger ```ledgerId``` to the entrylog.voidclose()voidflush()Flush any outstanding writes to disk.EntryLogMetadatagetEntryLogMetadata(long entryLogId, AbstractLogCompactor.Throttler throttler)Retrieve metadata for the given entrylog ID.java.util.Collection<java.lang.Long>getFlushedLogIds()Get the log ids for the set of logs which have been completely flushed to disk.java.util.Collection<CompactionEntryLog>incompleteCompactionLogs()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 java.io.FilelogFile(java.io.File directory, int logId)static java.lang.StringlogFilename(java.io.File directory, int logId)CompactionEntryLognewCompactionLog(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, wait
-
Methods inherited from interface org.apache.bookkeeper.bookie.storage.EntryLogger
getEntryLogMetadata
-
-
-
-
Constructor Detail
-
DirectEntryLogger
public DirectEntryLogger(java.io.File ledgerDir, EntryLogIds ids, NativeIO nativeIO, io.netty.buffer.ByteBufAllocator allocator, java.util.concurrent.ExecutorService writeExecutor, java.util.concurrent.ExecutorService flushExecutor, long maxFileSize, int maxSaneEntrySize, long totalWriteBufferSize, long totalReadBufferSize, int readBufferSize, int numReadThreads, int maxFdCacheTimeSeconds, Slogger slogParent, StatsLogger stats) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
addEntry
public long addEntry(long ledgerId, io.netty.buffer.ByteBuf buf) throws java.io.IOExceptionDescription 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:
java.io.IOException
-
readEntry
public io.netty.buffer.ByteBuf readEntry(long entryLocation) throws java.io.IOException, Bookie.NoEntryExceptionDescription 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:
java.io.IOExceptionBookie.NoEntryException
-
readEntry
public io.netty.buffer.ByteBuf readEntry(long ledgerId, long entryId, long entryLocation) throws java.io.IOException, Bookie.NoEntryExceptionDescription 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:
java.io.IOExceptionBookie.NoEntryException
-
flush
public void flush() throws java.io.IOExceptionDescription copied from interface:EntryLoggerFlush any outstanding writes to disk.- Specified by:
flushin interfaceEntryLogger- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceEntryLogger- Throws:
java.io.IOException
-
getFlushedLogIds
public java.util.Collection<java.lang.Long> 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
public void scanEntryLog(long entryLogId, EntryLogScanner scanner) throws java.io.IOExceptionDescription copied from interface:EntryLoggerScan the given entrylog, returning all entries contained therein.- Specified by:
scanEntryLogin interfaceEntryLogger- Throws:
java.io.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 java.io.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:
java.io.IOException
-
readEntryLogIndex
EntryLogMetadata readEntryLogIndex(long logId) throws java.io.IOException
- Throws:
java.io.IOException
-
scanEntryLogMetadata
EntryLogMetadata scanEntryLogMetadata(long logId, AbstractLogCompactor.Throttler throttler) throws java.io.IOException
- Throws:
java.io.IOException
-
newDirectReader
LogReader newDirectReader(int logId) throws java.io.IOException
- Throws:
java.io.IOException
-
logFile
public static java.io.File logFile(java.io.File directory, int logId)
-
logFilename
public static java.lang.String logFilename(java.io.File directory, int logId)
-
newCompactionLog
public CompactionEntryLog newCompactionLog(long srcLogId) throws java.io.IOException
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:
java.io.IOException
-
incompleteCompactionLogs
public java.util.Collection<CompactionEntryLog> 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
-
-