private void persist() {
    long flushIndex = currentIndex;
    if (flushIndex == lastFlushedIndex) {
      return;
    }
    File oldFile = new File(storageDir, prefix + lastFlushedIndex);
    File newFile = new File(storageDir, prefix + flushIndex);
    try {
      if (oldFile.exists()) {
        FileUtils.moveFile(oldFile, newFile);
        logger.debug(
            "version file updated, previous: {}, current: {}",
            oldFile.getAbsolutePath(),
            newFile.getAbsolutePath());
      } else {
        // In the normal state, this branch should not be triggered.
        // During the DataNode removing stage, the version file towards removing peer may be deleted
        // before all the async operations returns. We needn't add some sync operation here
        // because it won't infect the correctness
        logger.info(
            "failed to flush sync index because previous version file {} does not exists. "
                + "It may be caused by the target Peer is removed from current group. "
                + "target file is {}",
            oldFile.getAbsolutePath(),
            newFile.getAbsolutePath());
      }

      lastFlushedIndex = flushIndex;
    } catch (IOException e) {
      logger.error("Error occurred when flushing next version", e);
    }
  }
An index controller class to balance the performance degradation of frequent disk I/O.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IndexController.java