@InterfaceAudience.Private public class EditLogFileOutputStream extends EditLogOutputStream
EditLogOutputStream
, which
stores edits in a local file.Modifier and Type | Field and Description |
---|---|
static int |
MIN_PREALLOCATION_LENGTH |
Constructor and Description |
---|
EditLogFileOutputStream(Configuration conf,
File name,
int size)
Creates output buffers and file object.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Close the stream without necessarily flushing any pending data.
|
void |
close()
Close the journal.
|
void |
create()
Create empty edits logs file.
|
void |
flushAndSync(boolean durable)
Flush ready buffer to persistent store.
|
FileChannel |
getFileChannelForTesting() |
boolean |
isOpen() |
void |
setFileChannelForTesting(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.
|
String |
toString() |
void |
write(FSEditLogOp op)
Write edits log operation to the stream.
|
static void |
writeHeader(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, generateHtmlReport, getNumSync
public static final int MIN_PREALLOCATION_LENGTH
public EditLogFileOutputStream(Configuration conf, File name, int size) throws IOException
conf
- Configuration objectname
- File name to store edit logsize
- Size of flush bufferIOException
public void write(FSEditLogOp op) throws IOException
EditLogOutputStream
write
in class EditLogOutputStream
op
- operationIOException
public void writeRaw(byte[] bytes, int offset, int length) throws IOException
writeRaw
in class EditLogOutputStream
bytes
- the bytes to write.offset
- offset in the bytes to write fromlength
- number of bytes to writeIOException
public void create() throws IOException
create
in class EditLogOutputStream
IOException
public static void writeHeader(DataOutputStream out) throws IOException
out
- the output stream to write the header to.IOException
- in the event of error writing to the stream.public void close() throws IOException
EditLogOutputStream
close
in interface Closeable
close
in interface AutoCloseable
close
in class EditLogOutputStream
IOException
- if the journal can't be closed,
or if there are unflushed editspublic void abort() throws IOException
EditLogOutputStream
abort
in class EditLogOutputStream
IOException
public void setReadyToFlush() throws IOException
setReadyToFlush
in class EditLogOutputStream
IOException
public void flushAndSync(boolean durable) throws IOException
flushAndSync
in class EditLogOutputStream
durable
- if true, the edits should be made truly durable before
returningIOException
public boolean shouldForceSync()
EditLogOutputStream
shouldForceSync
in class EditLogOutputStream
public boolean isOpen()
public void setFileChannelForTesting(FileChannel fc)
public FileChannel getFileChannelForTesting()
public static void setShouldSkipFsyncForTesting(boolean skip)
skip
- true if fsync should not be calledCopyright © 2013 Apache Software Foundation. All rights reserved.