Class BinLog

  • All Implemented Interfaces:
    java.lang.Runnable

    public class BinLog
    extends java.lang.Object
    implements java.lang.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.
    • Method Detail

      • stop

        public void stop()
                  throws java.lang.InterruptedException
        Stop the consumer thread that writes log records. Can be called multiple times.
        Throws:
        java.lang.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

        public void put​(BinLog.ReleaseableWriteMarshallable record)
                 throws java.lang.InterruptedException
        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:
        java.lang.InterruptedException
      • run

        public void run()
        Specified by:
        run in interface java.lang.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 java.lang.Object
      • cleanDirectory

        public static java.lang.Throwable cleanDirectory​(File directory,
                                                         java.lang.Throwable accumulate)