Package org.apache.iotdb.db.wal.io
Class LogWriter
- java.lang.Object
-
- org.apache.iotdb.db.wal.io.LogWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ILogWriter
- Direct Known Subclasses:
CheckpointWriter,WALWriter
public abstract class LogWriter extends java.lang.Object implements ILogWriter
LogWriter writes the binary logs into a file, including writingWALEntryinto .wal file and writingCheckpointinto .checkpoint file.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.nio.channels.FileChannellogChannelprotected java.io.FilelogFileprotected java.io.FileOutputStreamlogStreamprotected longsize
-
Constructor Summary
Constructors Constructor Description LogWriter(java.io.File logFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidforce()Forces any updates to this file to be written to the storage device that contains it.voidforce(boolean metaData)Forces any updates to this file to be written to the storage device that contains it.java.io.FilegetLogFile()Gets the log filelongsize()Returns the current size of this file.voidwrite(java.nio.ByteBuffer buffer)Write given logs to a persistent medium.
-
-
-
Method Detail
-
write
public void write(java.nio.ByteBuffer buffer) throws java.io.IOExceptionDescription copied from interface:ILogWriterWrite given logs to a persistent medium. NOTICE: the logs may be cached in the storage device, if the storage device you are using do not guarantee strong persistence, and you want the logs to be persisted immediately, please callILogWriter.force()after calling this method. Notice: do not flip the buffer before calling this method- Specified by:
writein interfaceILogWriter- Parameters:
buffer- content that have been converted to bytes- Throws:
java.io.IOException- if an I/O error occurs
-
force
public void force() throws java.io.IOExceptionDescription copied from interface:ILogWriterForces any updates to this file to be written to the storage device that contains it.- Specified by:
forcein interfaceILogWriter- Throws:
java.io.IOException- if an I/O error occurs
-
force
public void force(boolean metaData) throws java.io.IOExceptionDescription copied from interface:ILogWriterForces any updates to this file to be written to the storage device that contains it.- Specified by:
forcein interfaceILogWriter- Parameters:
metaData- If true then this method is required to force changes to both the file's content and metadata to be written to storage; otherwise, it needs only force content changes to be written- Throws:
java.io.IOException- if an I/O error occurs
-
size
public long size()
Description copied from interface:ILogWriterReturns the current size of this file.- Specified by:
sizein interfaceILogWriter- Returns:
- size
-
getLogFile
public java.io.File getLogFile()
Description copied from interface:ILogWriterGets the log file- Specified by:
getLogFilein interfaceILogWriter- Returns:
- log file
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-