Class EditsDoubleBuffer

java.lang.Object
org.apache.hadoop.hdfs.server.namenode.EditsDoubleBuffer

@Private public class EditsDoubleBuffer extends Object
A double-buffer for edits. New edits are written into the first buffer while the second is available to be flushed. Each time the double-buffer is flushed, the two internal buffers are swapped. This allows edits to progress concurrently to flushes without allocating new buffers each time.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
  • Constructor Details

    • EditsDoubleBuffer

      public EditsDoubleBuffer(int defaultBufferSize)
  • Method Details

    • writeOp

      public void writeOp(FSEditLogOp op, int logVersion) throws IOException
      Throws:
      IOException
    • writeRaw

      public void writeRaw(byte[] bytes, int offset, int length) throws IOException
      Throws:
      IOException
    • close

      public void close() throws IOException
      Throws:
      IOException
    • setReadyToFlush

      public void setReadyToFlush()
    • flushTo

      public void flushTo(OutputStream out) throws IOException
      Writes the content of the "ready" buffer to the given output stream, and resets it. Does not swap any buffers.
      Throws:
      IOException
    • shouldForceSync

      public boolean shouldForceSync()
    • isFlushed

      public boolean isFlushed()
    • countBufferedBytes

      public int countBufferedBytes()
    • getFirstReadyTxId

      public long getFirstReadyTxId()
      Returns:
      the transaction ID of the first transaction ready to be flushed
    • countReadyTxns

      public int countReadyTxns()
      Returns:
      the number of transactions that are ready to be flushed
    • countReadyBytes

      public int countReadyBytes()
      Returns:
      the number of bytes that are ready to be flushed