Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 19C75200C26 for ; Fri, 10 Feb 2017 10:43:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 18738160B5B; Fri, 10 Feb 2017 09:43:05 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 66F6E160B5C for ; Fri, 10 Feb 2017 10:43:04 +0100 (CET) Received: (qmail 50504 invoked by uid 500); 10 Feb 2017 09:43:03 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 50489 invoked by uid 99); 10 Feb 2017 09:43:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Feb 2017 09:43:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3ADE9DFBDB; Fri, 10 Feb 2017 09:43:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: blerer@apache.org To: commits@cassandra.apache.org Date: Fri, 10 Feb 2017 09:43:03 -0000 Message-Id: <4e72cec4dcd64156936e6b74235af985@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] cassandra git commit: Use only one file pointer when creating commitlog segments archived-at: Fri, 10 Feb 2017 09:43:05 -0000 Repository: cassandra Updated Branches: refs/heads/cassandra-3.0 e885886d5 -> 9fca3cb15 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-3.0 Commit: 7680aebf10c34b05a24bdc925196038818ec5126 Parents: f0f9cf2 Author: Benjamin Lerer Authored: Fri Feb 10 10:25:34 2017 +0100 Committer: Benjamin Lerer 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) {