Interface EntryLogger

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
DefaultEntryLogger, DirectEntryLogger, ReadOnlyDefaultEntryLogger

public interface EntryLogger extends AutoCloseable
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 Details

  • Method Details

    • addEntry

      long addEntry(long ledgerId, io.netty.buffer.ByteBuf buf) throws IOException
      Add an entry for ledger ```ledgerId``` to the entrylog.
      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:
      IOException
    • readEntry

      io.netty.buffer.ByteBuf readEntry(long entryLocation) throws IOException, Bookie.NoEntryException
      Read an entry from an entrylog location.
      Parameters:
      entryLocation - the location from which to read the entry
      Returns:
      the entry
      Throws:
      IOException
      Bookie.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 match
      entryId - the entryID to match
      entryLocation - the location from which to read the entry
      Returns:
      the entry
      Throws:
      IOException
      Bookie.NoEntryException
    • flush

      void flush() throws IOException
      Flush any outstanding writes to disk.
      Throws:
      IOException
    • close

      void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException
    • newCompactionLog

      CompactionEntryLog newCompactionLog(long logToCompact) throws IOException
      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

      void scanEntryLog(long entryLogId, EntryLogScanner scanner) throws IOException
      Scan the given entrylog, returning all entries contained therein.
      Throws:
      IOException
    • getEntryLogMetadata

      default EntryLogMetadata getEntryLogMetadata(long entryLogId) 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
    • 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.