Class EditsDoubleBuffer
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.EditsDoubleBuffer
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intintintvoidflushTo(OutputStream out) Writes the content of the "ready" buffer to the given output stream, and resets it.longbooleanvoidbooleanvoidwriteOp(FSEditLogOp op, int logVersion) voidwriteRaw(byte[] bytes, int offset, int length)
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOG
-
-
Constructor Details
-
EditsDoubleBuffer
public EditsDoubleBuffer(int defaultBufferSize)
-
-
Method Details
-
writeOp
- Throws:
IOException
-
writeRaw
- Throws:
IOException
-
close
- Throws:
IOException
-
setReadyToFlush
public void setReadyToFlush() -
flushTo
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
-