Class BinLog
- java.lang.Object
-
- org.apache.cassandra.utils.binlog.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BinLog.Builder
static class
BinLog.ReleaseableWriteMarshallable
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.Throwable
cleanDirectory(File directory, java.lang.Throwable accumulate)
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.BinLogOptions
getBinLogOptions()
void
logRecord(BinLog.ReleaseableWriteMarshallable record)
boolean
offer(BinLog.ReleaseableWriteMarshallable record)
Offer a record to the log.void
put(BinLog.ReleaseableWriteMarshallable record)
Put a record into the log.void
run()
void
stop()
Stop the consumer thread that writes log records.
-
-
-
Field Detail
-
path
public final java.nio.file.Path path
-
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
TYPE
public static final java.lang.String TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getBinLogOptions
public BinLogOptions getBinLogOptions()
-
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 interfacejava.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 classjava.lang.Object
-
logRecord
public void logRecord(BinLog.ReleaseableWriteMarshallable record)
-
cleanDirectory
public static java.lang.Throwable cleanDirectory(File directory, java.lang.Throwable accumulate)
-
-