Class DirectEntryLogger

  • All Implemented Interfaces:
    java.lang.AutoCloseable, EntryLogger

    public class DirectEntryLogger
    extends java.lang.Object
    implements EntryLogger
    DirectEntryLogger.
    • 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 interface EntryLogger
        Parameters:
        ledgerId - the ledger for which the entry is being added
        buf - 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 interface EntryLogger
        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 interface EntryLogger
        Parameters:
        ledgerId - the ledgerID to match
        entryId - the entryID to match
        entryLocation - 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 interface EntryLogger
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface EntryLogger
        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 interface EntryLogger
      • removeEntryLog

        public boolean removeEntryLog​(long entryLogId)
        Description copied from interface: EntryLogger
        Delete the entrylog with the given ID.
        Specified by:
        removeEntryLog in interface EntryLogger
        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 interface EntryLogger
        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 interface EntryLogger
      • 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 interface EntryLogger
        Throws:
        java.io.IOException
      • readEntryLogIndex

        EntryLogMetadata readEntryLogIndex​(long logId)
                                    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 interface EntryLogger
        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 interface EntryLogger