kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkr...@apache.org
Subject [1/2] git commit: KAFKA-1036 Close checkpoint file before renaming it for Windows compatibility.
Date Tue, 15 Oct 2013 21:07:50 GMT
Updated Branches:
  refs/heads/trunk a160f1023 -> ccdb56201


KAFKA-1036 Close checkpoint file before renaming it for Windows compatibility.


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/ccdb5620
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/ccdb5620
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/ccdb5620

Branch: refs/heads/trunk
Commit: ccdb56201e494d6025e47a48c82f233ccc9386ac
Parents: c98b6de
Author: Jay Kreps <jay.kreps@gmail.com>
Authored: Wed Oct 9 16:55:49 2013 -0700
Committer: Jay Kreps <jay.kreps@gmail.com>
Committed: Tue Oct 15 14:06:48 2013 -0700

----------------------------------------------------------------------
 core/src/main/scala/kafka/log/OffsetIndex.scala     |  2 +-
 .../main/scala/kafka/server/OffsetCheckpoint.scala  | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/ccdb5620/core/src/main/scala/kafka/log/OffsetIndex.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/log/OffsetIndex.scala b/core/src/main/scala/kafka/log/OffsetIndex.scala
index aa654e8..80dd430 100644
--- a/core/src/main/scala/kafka/log/OffsetIndex.scala
+++ b/core/src/main/scala/kafka/log/OffsetIndex.scala
@@ -301,7 +301,7 @@ class OffsetIndex(@volatile var file: File, val baseOffset: Long, val
maxIndexSi
   /**
    * Forcefully free the buffer's mmap. We do this only on windows.
    */
-  def forceUnmap(m: MappedByteBuffer) {
+  private def forceUnmap(m: MappedByteBuffer) {
     try {
       if(m.isInstanceOf[sun.nio.ch.DirectBuffer])
         (m.asInstanceOf[sun.nio.ch.DirectBuffer]).cleaner().clean()

http://git-wip-us.apache.org/repos/asf/kafka/blob/ccdb5620/core/src/main/scala/kafka/server/OffsetCheckpoint.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/kafka/server/OffsetCheckpoint.scala b/core/src/main/scala/kafka/server/OffsetCheckpoint.scala
index 815c90d..b5719f8 100644
--- a/core/src/main/scala/kafka/server/OffsetCheckpoint.scala
+++ b/core/src/main/scala/kafka/server/OffsetCheckpoint.scala
@@ -53,17 +53,17 @@ class OffsetCheckpoint(val file: File) extends Logging {
       
         // flush and overwrite old file
         writer.flush()
-        // swap new offset checkpoint file with previous one
-        if(!temp.renameTo(file)) {
-          // renameTo() fails on Windows if the destination file exists.
-          file.delete()
-          if(!temp.renameTo(file)) {
-            throw new IOException("File rename from %s to %s failed.".format(temp.getAbsolutePath,
file.getAbsolutePath))
-          }
-        }
       } finally {
         writer.close()
       }
+      
+      // swap new offset checkpoint file with previous one
+      if(!temp.renameTo(file)) {
+        // renameTo() fails on Windows if the destination file exists.
+        file.delete()
+        if(!temp.renameTo(file))
+          throw new IOException("File rename from %s to %s failed.".format(temp.getAbsolutePath,
file.getAbsolutePath))
+      }
     }
   }
 


Mime
View raw message