mychaow commented on a change in pull request #1721:
URL: https://github.com/apache/iotdb/pull/1721#discussion_r542153576



##########
File path: server/src/main/java/org/apache/iotdb/db/writelog/io/LogWriter.java
##########
@@ -18,36 +18,59 @@
  */
 package org.apache.iotdb.db.writelog.io;
 
+import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory;
+import org.apache.iotdb.db.utils.TestOnly;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
 import java.nio.channels.FileChannel;
 import java.util.zip.CRC32;
-import org.apache.iotdb.db.conf.IoTDBConfig;
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory;
 
 /**
- * LogWriter writes the binarized logs into a file using FileChannel together 
with check sums of
+ * LogWriter writes the binary logs into a file using FileChannel together 
with check sums of
  * each log calculated using CRC32.
  */
 public class LogWriter implements ILogWriter {
+  private static final Logger logger = 
LoggerFactory.getLogger(LogWriter.class);
 
   private File logFile;
   private FileOutputStream fileOutputStream;
   private FileChannel channel;
-  private CRC32 checkSummer = new CRC32();
-  private IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
-  private ByteBuffer lengthBuffer = ByteBuffer.allocate(4);
-  private ByteBuffer checkSumBuffer = ByteBuffer.allocate(8);
+  private final CRC32 checkSummer = new CRC32();
+  private final ByteBuffer lengthBuffer = ByteBuffer.allocate(4);
+  private final ByteBuffer checkSumBuffer = ByteBuffer.allocate(8);
+  private final long forcePeriodInMs;
 
-  public LogWriter(String logFilePath) {
+  /**
+   * @param logFilePath
+   * @param forcePeriodInMs
+   * @throws FileNotFoundException
+   */
+  @TestOnly
+  public LogWriter(String logFilePath, long forcePeriodInMs) throws 
FileNotFoundException {
     logFile = SystemFileFactory.INSTANCE.getFile(logFilePath);
+    this.forcePeriodInMs = forcePeriodInMs;
+
+    if (channel == null) {

Review comment:
       yes, but I think add a check is not redundancy




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to