kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 翟玉勇 (JIRA) <j...@apache.org>
Subject [jira] [Created] (KAFKA-7442) forceUnmap mmap on linux
Date Wed, 26 Sep 2018 07:07:00 GMT
翟玉勇 created KAFKA-7442:
--------------------------

             Summary: forceUnmap mmap on linux
                 Key: KAFKA-7442
                 URL: https://issues.apache.org/jira/browse/KAFKA-7442
             Project: Kafka
          Issue Type: Improvement
          Components: log
    Affects Versions: 0.10.1.1
            Reporter: 翟玉勇


when resize OffsetIndex or TimeIndex,We should force unmap mmap for linux platform

{code}
def resize(newSize: Int) {
    inLock(lock) {
      val raf = new RandomAccessFile(_file, "rw")
      val roundedNewSize = roundDownToExactMultiple(newSize, entrySize)
      val position = mmap.position

      /* Windows won't let us modify the file length while the file is mmapped :-( */
      if(Os.isWindows)
        forceUnmap(mmap)
      try {
        raf.setLength(roundedNewSize)
        mmap = raf.getChannel().map(FileChannel.MapMode.READ_WRITE, 0, roundedNewSize)
        _maxEntries = mmap.limit / entrySize
        mmap.position(position)
      } finally {
        CoreUtils.swallow(raf.close())
      }
    }
  }
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message