Interface RaftLogFlusher

All Superinterfaces:
AutoCloseable, CloseableSilently
All Known Implementing Classes:
DelayedFlusher, RaftLogFlusher.DirectFlusher, RaftLogFlusher.NoopFlusher
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface RaftLogFlusher extends CloseableSilently
Configurable flush strategy for the RaftLog. You can use its implementations to improve performance at the cost of safety.

The default strategy is RaftLogFlusher.DirectFlusher, which is the safest but slowest option.

The RaftLogFlusher.NoopFlusher is the fastest but most dangerous option, as it will defer flushing to the operating system. It's then possible to run into data corruption or data loss issues. Please refer to the documentation regarding this.

DelayedFlusher can be configured to provide a trade-off between performance and safety. This will cause flushes to be performed in a delayed fashion. See its documentation for more. You should pick this if RaftLogFlusher.DirectFlusher does not provide the desired performance, but you still wish a lower likelihood of corruption issues than with RaftLogFlusher.NoopFlusher. The recommended configuration would be to find the smallest possible delay with which you achieve your performance goals.

  • Method Details

    • flush

      void flush(Journal journal)
      Signals that there is data to be flushed in the journal. The implementation may or may not immediately flush this.
      Parameters:
      journal - the journal to flush
    • isDirect

      default boolean isDirect()
      If this returns true, then any calls to flush(Journal) are synchronous and immediate, and any guarantees offered by the implementation will hold after a call to flush(Journal).
    • close

      default void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface CloseableSilently