Class BinLog

java.lang.Object
org.apache.cassandra.utils.binlog.BinLog
All Implemented Interfaces:
Runnable

public class BinLog extends Object implements Runnable
Bin log is a is quick and dirty binary log that is kind of a NIH version of binary logging with a traditional logging framework. It's goal is good enough performance, predictable footprint, simplicity in terms of implementation and configuration and most importantly minimal impact on producers of log records. Performance safety is accomplished by feeding items to the binary log using a weighted queue and dropping records if the binary log falls sufficiently far behind. Simplicity and good enough perforamance is achieved by using a single log writing thread as well as Chronicle Queue to handle writing the log, making it available for readers, as well as log rolling.
  • Field Details

  • Method Details

    • getBinLogOptions

      public BinLogOptions getBinLogOptions()
    • stop

      public void stop() throws InterruptedException
      Stop the consumer thread that writes log records. Can be called multiple times.
      Throws:
      InterruptedException
    • offer

      public boolean offer(BinLog.ReleaseableWriteMarshallable record)
      Offer a record to the log. If the in memory queue is full the record will be dropped and offer will return false.
      Parameters:
      record - The record to write to the log
      Returns:
      true if the record was queued and false otherwise
    • put

      Put a record into the log. If the in memory queue is full the putting thread will be blocked until there is space or it is interrupted.
      Parameters:
      record - The record to write to the log
      Throws:
      InterruptedException
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • finalize

      public void finalize()
      There is a race where we might not release a buffer, going to let finalization catch it since it shouldn't happen to a lot of buffers. Only test code would run into it anyways.
      Overrides:
      finalize in class Object
    • logRecord

      public void logRecord(BinLog.ReleaseableWriteMarshallable record)
    • cleanDirectory

      public static Throwable cleanDirectory(File directory, Throwable accumulate)