public StoreTxLog(
      StoreConfig storeConfig, File file, boolean readonly, boolean isNewFile, long firstRecordId)
      throws IOException {
    this.storeConfig = storeConfig;
    this.entryBuffer = ByteBuffer.allocate(storeConfig.getMaxxLogEntryLength() + 1 + 4);
    this.fileHeader = new StoreTxLogFileHeader();

    if (!readonly) {
      syncTimer = new Timer("ltsdb-dblog-sync-timer", true);

      syncCallable =
          new FutureTimerTask.Callable() {
            @Override
            public void call() throws Exception {
              checkPoint();
            }
          };
    }

    if (isNewFile && file.exists()) {
      throw new IOException(file + " exists already");
    } else {
      FileUtils.createFileIfNotExist(file);
    }

    fileChannel = FileUtils.newFileChannel(file, "rw");

    if (isNewFile) {
      // 新文件长度为头部长度
      fileLength = fileHeader.getLength();
      fileHeader.setFirstRecordId(firstRecordId);

      fileHeader.write(fileChannel);
    } else {
      fileHeader.read(fileChannel);
      fileLength = fileChannel.size();
      lastCheckPointLength = fileLength;
    }
  }
 public int getHeaderLength() {
   return fileHeader.getLength();
 }