Class WALBuffer

  • All Implemented Interfaces:
    java.lang.AutoCloseable, IWALBuffer

    public class WALBuffer
    extends AbstractWALBuffer
    This buffer guarantees the concurrent safety and uses double buffers mechanism to accelerate writes and avoid waiting for buffer syncing to disk.
    • Field Detail

      • currentFileStatus

        protected volatile WALFileStatus currentFileStatus
        file status of working buffer, updating file writer's status when syncing
    • Constructor Detail

      • WALBuffer

        public WALBuffer​(java.lang.String identifier,
                         java.lang.String logDirectory)
                  throws java.io.FileNotFoundException
        Throws:
        java.io.FileNotFoundException
      • WALBuffer

        public WALBuffer​(java.lang.String identifier,
                         java.lang.String logDirectory,
                         long startFileVersion,
                         long startSearchIndex)
                  throws java.io.FileNotFoundException
        Throws:
        java.io.FileNotFoundException
    • Method Detail

      • write

        public void write​(WALEntry walEntry)
        Description copied from interface: IWALBuffer
        Write WALEntry into wal buffer.
        Parameters:
        walEntry - info will be written into wal buffer
      • waitForFlush

        public void waitForFlush()
                          throws java.lang.InterruptedException
        Description copied from interface: IWALBuffer
        Wait for next flush operation done
        Throws:
        java.lang.InterruptedException
      • waitForFlush

        public boolean waitForFlush​(long time,
                                    java.util.concurrent.TimeUnit unit)
                             throws java.lang.InterruptedException
        Description copied from interface: IWALBuffer
        Wait for next flush operation done
        Throws:
        java.lang.InterruptedException
      • close

        public void close()
      • isAllWALEntriesConsumed

        public boolean isAllWALEntriesConsumed()