java.io.Closeable, java.lang.AutoCloseable@Private public class EditLogFileOutputStream extends EditLogOutputStream
EditLogOutputStream, which
stores edits in a local file.| Modifier and Type | Field | Description |
|---|---|---|
static int |
MIN_PREALLOCATION_LENGTH |
| Constructor | Description |
|---|---|
EditLogFileOutputStream(org.apache.hadoop.conf.Configuration conf,
java.io.File name,
int size) |
Creates output buffers and file object.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
abort() |
Close the stream without necessarily flushing any pending data.
|
void |
close() |
Close the journal.
|
void |
create(int layoutVersion) |
Create empty edits logs file.
|
void |
flushAndSync(boolean durable) |
Flush ready buffer to persistent store.
|
java.nio.channels.FileChannel |
getFileChannelForTesting() |
|
boolean |
isOpen() |
|
void |
setFileChannelForTesting(java.nio.channels.FileChannel fc) |
|
void |
setReadyToFlush() |
All data that has been written to the stream so far will be flushed.
|
static void |
setShouldSkipFsyncForTesting(boolean skip) |
For the purposes of unit tests, we don't need to actually
write durably to disk.
|
boolean |
shouldForceSync() |
Implement the policy when to automatically sync the buffered edits log
The buffered edits can be flushed when the buffer becomes full or
a certain period of time is elapsed.
|
java.lang.String |
toString() |
|
void |
write(FSEditLogOp op) |
Write edits log operation to the stream.
|
static void |
writeHeader(int layoutVersion,
java.io.DataOutputStream out) |
Write header information for this EditLogFileOutputStream to the provided
DataOutputSream.
|
void |
writeRaw(byte[] bytes,
int offset,
int length) |
Write a transaction to the stream.
|
flush, flush, generateReport, getCurrentLogVersion, getLastJournalledTxId, getNumSync, setCurrentLogVersionpublic static final int MIN_PREALLOCATION_LENGTH
public EditLogFileOutputStream(org.apache.hadoop.conf.Configuration conf,
java.io.File name,
int size)
throws java.io.IOException
conf - Configuration objectname - File name to store edit logsize - Size of flush bufferjava.io.IOExceptionpublic void write(FSEditLogOp op) throws java.io.IOException
EditLogOutputStreamwrite in class EditLogOutputStreamop - operationjava.io.IOExceptionpublic void writeRaw(byte[] bytes,
int offset,
int length)
throws java.io.IOException
writeRaw in class EditLogOutputStreambytes - the bytes to write.offset - offset in the bytes to write fromlength - number of bytes to writejava.io.IOExceptionpublic void create(int layoutVersion)
throws java.io.IOException
create in class EditLogOutputStreamlayoutVersion - The LayoutVersion of the journaljava.io.IOException@VisibleForTesting
public static void writeHeader(int layoutVersion,
java.io.DataOutputStream out)
throws java.io.IOException
layoutVersion - the LayoutVersion of the EditLogout - the output stream to write the header to.java.io.IOException - in the event of error writing to the stream.public void close()
throws java.io.IOException
EditLogOutputStreamclose in interface java.lang.AutoCloseableclose in interface java.io.Closeableclose in class EditLogOutputStreamjava.io.IOException - if the journal can't be closed,
or if there are unflushed editspublic void abort()
throws java.io.IOException
EditLogOutputStreamabort in class EditLogOutputStreamjava.io.IOExceptionpublic void setReadyToFlush()
throws java.io.IOException
setReadyToFlush in class EditLogOutputStreamjava.io.IOExceptionpublic void flushAndSync(boolean durable)
throws java.io.IOException
flushAndSync in class EditLogOutputStreamdurable - if true, the edits should be made truly durable before
returningjava.io.IOExceptionpublic boolean shouldForceSync()
EditLogOutputStreamshouldForceSync in class EditLogOutputStreampublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isOpen()
@VisibleForTesting public void setFileChannelForTesting(java.nio.channels.FileChannel fc)
@VisibleForTesting public java.nio.channels.FileChannel getFileChannelForTesting()
@VisibleForTesting public static void setShouldSkipFsyncForTesting(boolean skip)
skip - true if fsync should not be calledCopyright © 2008–2025 Apache Software Foundation. All rights reserved.