private void endFile() throws IOException {
    WALSignalEntry endMarker = new WALSignalEntry(WALEntryType.WAL_FILE_INFO_END_MARKER);
    ByteBuffer markerBuffer = ByteBuffer.allocate(Byte.BYTES);
    // mark info part ends
    endMarker.serialize(markerBuffer);
    write(markerBuffer, false);
    int metaDataSize = metaData.serializedSize();

    ByteBuffer buffer =
        ByteBuffer.allocate(metaDataSize + Integer.BYTES + version.getVersionBytes().length);
    // flush meta data
    metaData.serialize(buffer);
    buffer.putInt(metaDataSize);
    // add magic string
    buffer.put(version.getVersionBytes());
    writeMetadata(buffer);
  }
Writes buffer and update its' metadata.

@throws IOException when failing to write
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/io/WALWriter.java