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 long
addEntry(long ledgerId, io.netty.buffer.ByteBuf buf)
Add an entry for ledger ```ledgerId``` to the entrylog.void
close()
void
flush()
Flush any outstanding writes to disk.EntryLogMetadata
getEntryLogMetadata(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.boolean
logExists(long logId)
Check whether an entrylog with the given ID exists.static java.io.File
logFile(java.io.File directory, int logId)
static java.lang.String
logFilename(java.io.File directory, int logId)
CompactionEntryLog
newCompactionLog(long srcLogId)
Create a new entrylog into which compacted entries can be added.(package private) LogReader
newDirectReader(int logId)
io.netty.buffer.ByteBuf
readEntry(long entryLocation)
Read an entry from an entrylog location.io.netty.buffer.ByteBuf
readEntry(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) EntryLogMetadata
readEntryLogIndex(long logId)
boolean
removeEntryLog(long entryLogId)
Delete the entrylog with the given ID.void
scanEntryLog(long entryLogId, EntryLogScanner scanner)
Scan the given entrylog, returning all entries contained therein.(package private) EntryLogMetadata
scanEntryLogMetadata(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.IOException
Description copied from interface:EntryLogger
Add an entry for ledger ```ledgerId``` to the entrylog.- Specified by:
addEntry
in 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.NoEntryException
Description copied from interface:EntryLogger
Read an entry from an entrylog location.- Specified by:
readEntry
in interfaceEntryLogger
- Parameters:
entryLocation
- the location from which to read the entry- Returns:
- the entry
- Throws:
java.io.IOException
Bookie.NoEntryException
-
readEntry
public io.netty.buffer.ByteBuf readEntry(long ledgerId, long entryId, long entryLocation) throws java.io.IOException, Bookie.NoEntryException
Description copied from interface:EntryLogger
Read an entry from an entrylog location, and verify that is matches the expected ledger and entry ID.- Specified by:
readEntry
in 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.IOException
Bookie.NoEntryException
-
flush
public void flush() throws java.io.IOException
Description copied from interface:EntryLogger
Flush any outstanding writes to disk.- Specified by:
flush
in interfaceEntryLogger
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceEntryLogger
- Throws:
java.io.IOException
-
getFlushedLogIds
public java.util.Collection<java.lang.Long> getFlushedLogIds()
Description copied from interface:EntryLogger
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.- Specified by:
getFlushedLogIds
in interfaceEntryLogger
-
removeEntryLog
public boolean removeEntryLog(long entryLogId)
Description copied from interface:EntryLogger
Delete the entrylog with the given ID.- Specified by:
removeEntryLog
in interfaceEntryLogger
- Returns:
- false if the entrylog doesn't exist.
-
scanEntryLog
public void scanEntryLog(long entryLogId, EntryLogScanner scanner) throws java.io.IOException
Description copied from interface:EntryLogger
Scan the given entrylog, returning all entries contained therein.- Specified by:
scanEntryLog
in interfaceEntryLogger
- Throws:
java.io.IOException
-
logExists
public boolean logExists(long logId)
Description copied from interface:EntryLogger
Check whether an entrylog with the given ID exists.- Specified by:
logExists
in interfaceEntryLogger
-
getEntryLogMetadata
public EntryLogMetadata getEntryLogMetadata(long entryLogId, AbstractLogCompactor.Throttler throttler) throws java.io.IOException
Description copied from interface:EntryLogger
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.- Specified by:
getEntryLogMetadata
in 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:EntryLogger
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.- Specified by:
newCompactionLog
in interfaceEntryLogger
- Throws:
java.io.IOException
-
incompleteCompactionLogs
public java.util.Collection<CompactionEntryLog> incompleteCompactionLogs()
Description copied from interface:EntryLogger
Return a collection of all the compaction entry logs which have been compacted, but have not been cleaned up.- Specified by:
incompleteCompactionLogs
in interfaceEntryLogger
-
-