@Override
  public void write(ByteBuffer logBuffer) throws IOException {
    if (channel == null) {
      fileOutputStream = new FileOutputStream(logFile, true);
      channel = fileOutputStream.getChannel();
    }
    logBuffer.flip();
    int logSize = logBuffer.limit();
    // 4 bytes size and 8 bytes check sum

    checkSummer.reset();
    checkSummer.update(logBuffer);
    long checkSum = checkSummer.getValue();

    logBuffer.flip();

    lengthBuffer.clear();
    checkSumBuffer.clear();
    lengthBuffer.putInt(logSize);
    checkSumBuffer.putLong(checkSum);
    lengthBuffer.flip();
    checkSumBuffer.flip();

    try {
      channel.write(lengthBuffer);
      channel.write(logBuffer);
      channel.write(checkSumBuffer);

      if (this.forceEachWrite) {
        channel.force(true);
      }
    } catch (ClosedChannelException ignored) {
      logger.warn("someone interrupt current thread, so no need to do write for io safety");
    }
  }
LogWriter writes the binary logs into a file using FileChannel together with check sums of each
log calculated using CRC32.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/writelog/LogWriter.java