private void flush() {
    File tempFile = new File(file.getAbsolutePath() + ".tmp");
    try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
      CrcOutputStream crcOutputStream = new CrcOutputStream(fileOutputStream);
      DataOutputStream stream = new DataOutputStream(crcOutputStream);
      stream.writeShort(version); // If we read this log from file, then keep this the same version.
      switch (version) {
        case VERSION_0:
          flushVersion0(stream);
          break;
        case VERSION_1:
        case VERSION_2:
          flushVersion1And2(stream);
          break;
      }
      stream.writeLong(crcOutputStream.getValue());
      fileOutputStream.getChannel().force(true);
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
    if (!tempFile.renameTo(file)) {
      throw new IllegalStateException("Newly written compaction log could not be saved");
    }
  }
Flushes all changes to the file backing this compaction log.
ambry-store/src/main/java/com/github/ambry/store/CompactionLog.java