You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by bl...@apache.org on 2017/02/10 09:39:03 UTC

cassandra git commit: Use only one file pointer when creating commitlog segments

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 f0f9cf232 -> 7680aebf1


Use only one file pointer when creating commitlog segments

patch by Benjamin Lerer; reviewed by Joshua McKenzie for CASSANDRA-12539


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

Branch: refs/heads/cassandra-2.2
Commit: 7680aebf10c34b05a24bdc925196038818ec5126
Parents: f0f9cf2
Author: Benjamin Lerer <b....@gmail.com>
Authored: Fri Feb 10 10:25:34 2017 +0100
Committer: Benjamin Lerer <b....@gmail.com>
Committed: Fri Feb 10 10:25:34 2017 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |  1 +
 .../db/commitlog/MemoryMappedSegment.java          | 17 ++---------------
 2 files changed, 3 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7680aebf/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c8419ab..4295dd8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.9
+ * Use only one file pointer when creating commitlog segments (CASSANDRA-12539)
  * Fix speculative retry bugs (CASSANDRA-13009)
  * Fix handling of nulls and unsets in IN conditions (CASSANDRA-12981) 
  * Remove support for non-JavaScript UDFs (CASSANDRA-12883)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7680aebf/src/java/org/apache/cassandra/db/commitlog/MemoryMappedSegment.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/commitlog/MemoryMappedSegment.java b/src/java/org/apache/cassandra/db/commitlog/MemoryMappedSegment.java
index e240a91..fa9ef37 100644
--- a/src/java/org/apache/cassandra/db/commitlog/MemoryMappedSegment.java
+++ b/src/java/org/apache/cassandra/db/commitlog/MemoryMappedSegment.java
@@ -18,7 +18,6 @@
 package org.apache.cassandra.db.commitlog;
 
 import java.io.IOException;
-import java.io.RandomAccessFile;
 import java.nio.ByteBuffer;
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
@@ -55,21 +54,9 @@ public class MemoryMappedSegment extends CommitLogSegment
     {
         try
         {
-            // Extend the file size to the standard segment size.
-            // NOTE: while we're using RAF to easily adjust file size, we need to avoid using RAF
-            // for grabbing the FileChannel due to FILE_SHARE_DELETE flag bug on windows.
-            // See: https://bugs.openjdk.java.net/browse/JDK-6357433 and CASSANDRA-8308
-            try (RandomAccessFile raf = new RandomAccessFile(logFile, "rw"))
-            {
-                raf.setLength(DatabaseDescriptor.getCommitLogSegmentSize());
-            }
-            catch (IOException e)
-            {
-                throw new FSWriteError(e, logFile);
-            }
+            MappedByteBuffer mappedFile = channel.map(FileChannel.MapMode.READ_WRITE, 0, DatabaseDescriptor.getCommitLogSegmentSize());
             commitLog.allocator.addSize(DatabaseDescriptor.getCommitLogSegmentSize());
-
-            return channel.map(FileChannel.MapMode.READ_WRITE, 0, DatabaseDescriptor.getCommitLogSegmentSize());
+            return mappedFile;
         }
         catch (IOException e)
         {