Class LogWriter
- java.lang.Object
-
- org.apache.iotdb.db.utils.writelog.LogWriter
-
- All Implemented Interfaces:
ILogWriter
public class LogWriter extends java.lang.Object implements ILogWriter
LogWriter writes the binary logs into a file using FileChannel together with check sums of each log calculated using CRC32.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()release resources occupied by this object, like file streams.voidforce()force the OS/FileSystem to flush its cache to make sure logs are persisted.java.lang.StringtoString()voidwrite(java.nio.ByteBuffer logBuffer)Write given logs to a persistent medium.
-
-
-
Constructor Detail
-
LogWriter
public LogWriter(java.lang.String logFilePath, boolean forceEachWrite) throws java.io.FileNotFoundException- Parameters:
logFilePath-forceEachWrite-- Throws:
java.io.FileNotFoundException
-
LogWriter
public LogWriter(java.io.File logFile, boolean forceEachWrite) throws java.io.FileNotFoundException- Throws:
java.io.FileNotFoundException
-
-
Method Detail
-
write
public void write(java.nio.ByteBuffer logBuffer) throws java.io.IOExceptionDescription copied from interface:ILogWriterWrite given logs to a persistent medium. NOTICE: the logs may be cached in the OS/FileSystem, if the OS/FileSystem you are using do not guarantee strong persistency and you want the logs to be persisted immediately, please call force() after calling this method. Notice: do not flip the buffer before calling this method- Specified by:
writein interfaceILogWriter- Parameters:
logBuffer- WAL logs that have been converted to bytes- Throws:
java.io.IOException
-
force
public void force() throws java.io.IOExceptionDescription copied from interface:ILogWriterforce the OS/FileSystem to flush its cache to make sure logs are persisted.- Specified by:
forcein interfaceILogWriter- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:ILogWriterrelease resources occupied by this object, like file streams.- Specified by:
closein interfaceILogWriter- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-