Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: adjust space

...

  1. If do clear shutdown,  the last log file will be truncated to its real size since the close() function of FileMessageSet will call trim(),
  2. If crash, then when restart,  will go through the process of recover() and the last log file will be truncate to its real size, (and the position will be moved to end of the file)
  3. When service start and open existing file
    1. Will run the LogSegment constructor which has NO parameter "preallocate",
    2. Then in FileMessageSet,  the "end" in FileMessageSet will be Int.MaxValue,   and then "channel.position(math.min(channel.size().toInt, end))"  will make the position be end of the file,
    3. If recover needed, the recover function will truncate file to end of valid data, and also move the position to it,
  4.  

    When service running and need create new log segment and new FileMessageSet
    1. If preallocate = true
      1. the "end" in FileMessageSet will be 0,  the file size will be "initFileSize", and then "channel.position(math.min(channel.size().toInt, end))"  will make the position be 0,
    2. Else if preallocate = false
      1. backward compatible, the "end" in FileMessageSet will be Int.MaxValue, the file size will be "0",  and then "channel.position(math.min(channel.size().toInt, end))"  will make the position be 0,

...