Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

log.preallocate  - Should pre allocate file when create new segment?  Default value is false for backward compatible. If you are using Kafka on Windows, you probably need set it to true.

Proposed Changes

  1. Configuration - add one configuration item "log.preallocate",  parse it in KafkaConfig.scala, and transfer to KafkaServer.scala, LogConfig.scala.
  2. In Log.scala 
    1.  add one function initFileSize().  if the log preallocation is enabled, the value is config.segmentSize - 2 * config.maxMessageSize,  else the value is 0.
    2.  pass the initFileSize and config.preallocate to LogSegment when need create one LogSegment.
    3.  When need roll to a new file, trim log file of active segment
  3. In LogSegment.scala - pass the initFileSize and preallocation to FileMessageSet.
  4. In FileMessageSet.scala 
    1.  add one function trim().  Call it when close or roll a new LogSegment.
    2. Move openChannel from CoreUtil.scala and add two more parameter "initFileSize" and "preallocate".
    3. Add one constructor function with two more parameters  "initFileSize" and "preallocate".
  5. In CoreUtils.scala
    1. Move openChallel to FileMessageSet.scala

Compatibility, Deprecation, and Migration Plan

This change is fully backward compatible.

Rejected Alternatives