[4/6] git commit: avoid blocking additional writes during flush patch by jbellis; reviewed by slebresnse and tested by brandonwilliams for CASSANDRA-1991

2012-05-09 Thread jbellis
avoid blocking additional writes during flush
patch by jbellis; reviewed by slebresnse and tested by brandonwilliams for 
CASSANDRA-1991


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

Branch: refs/heads/trunk
Commit: 4d7e703561bc68a79d856e28b3f710455b1c70bf
Parents: aead8da
Author: Jonathan Ellis jbel...@apache.org
Authored: Wed May 9 14:51:24 2012 -0500
Committer: Jonathan Ellis jbel...@apache.org
Committed: Wed May 9 14:52:06 2012 -0500

--
 CHANGES.txt|2 +
 .../org/apache/cassandra/db/ColumnFamilyStore.java |   12 +++---
 src/java/org/apache/cassandra/db/Memtable.java |   12 +++---
 .../apache/cassandra/db/commitlog/CommitLog.java   |   19 +++
 .../db/compaction/LeveledCompactionStrategy.java   |   25 +--
 .../cassandra/db/compaction/LeveledManifest.java   |9 +
 .../org/apache/cassandra/db/CommitLogTest.java |6 ++--
 7 files changed, 53 insertions(+), 32 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d7e7035/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index d6e62c8..0888d29 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,8 @@
 
 
 1.1.1-dev
+ * avoid blocking additional writes during flush when the commitlog
+   gets behind temporarily (CASSANDRA-1991)
  * enable caching on index CFs based on data CF cache setting (CASSANDRA-4197)
  * warn on invalid replication strategy creation options (CASSANDRA-4046)
  * remove [Freeable]Memory finalizers (CASSANDRA-4222)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4d7e7035/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
--
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java 
b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index ea9bf21..05eaa83 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -30,6 +30,7 @@ import java.util.regex.Pattern;
 import javax.management.*;
 
 import com.google.common.collect.*;
+import com.google.common.util.concurrent.Futures;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -608,8 +609,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 }
 
 assert getMemtableThreadSafe() == oldMemtable;
-final ReplayPosition ctx = writeCommitLog ? 
CommitLog.instance.getContext() : ReplayPosition.NONE;
-logger.debug(flush position is {}, ctx);
+final FutureReplayPosition ctx = writeCommitLog ? 
CommitLog.instance.getContext() : Futures.immediateFuture(ReplayPosition.NONE);
 
 // submit the memtable for any indexed sub-cfses, and our own.
 final ListColumnFamilyStore icc = new 
ArrayListColumnFamilyStore();
@@ -641,7 +641,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 // while keeping the wait-for-flush (future.get) out of anything 
latency-sensitive.
 return postFlushExecutor.submit(new WrappedRunnable()
 {
-public void runMayThrow() throws InterruptedException, 
IOException
+public void runMayThrow() throws InterruptedException, 
IOException, ExecutionException
 {
 latch.await();
 
@@ -661,7 +661,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 {
 // if we're not writing to the commit log, we are 
replaying the log, so marking
 // the log header with you can discard anything 
written before the context is not valid
-
CommitLog.instance.discardCompletedSegments(metadata.cfId, ctx);
+
CommitLog.instance.discardCompletedSegments(metadata.cfId, ctx.get());
 }
 }
 });
@@ -1709,13 +1709,13 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 if (ksm.durableWrites)
 {
 CommitLog.instance.forceNewSegment();
-ReplayPosition position = CommitLog.instance.getContext();
+FutureReplayPosition position = CommitLog.instance.getContext();
 // now flush everyone else.  re-flushing ourselves is not 
necessary, but harmless
 for (ColumnFamilyStore cfs : ColumnFamilyStore.all())
 cfs.forceFlush();
 waitForActiveFlushes();
 // if everything was clean, flush won't have 

[4/6] git commit: avoid blocking additional writes during flush patch by jbellis; reviewed by slebresnse and tested by brandonwilliams for CASSANDRA-1991

2012-05-09 Thread jbellis
avoid blocking additional writes during flush
patch by jbellis; reviewed by slebresnse and tested by brandonwilliams for 
CASSANDRA-1991


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

Branch: refs/heads/trunk
Commit: 08848e7956f5fd08525a08498205637b2652f2a7
Parents: 67ed39f
Author: Jonathan Ellis jbel...@apache.org
Authored: Wed May 9 14:51:24 2012 -0500
Committer: Jonathan Ellis jbel...@apache.org
Committed: Wed May 9 14:52:18 2012 -0500

--
 CHANGES.txt|2 +
 .../org/apache/cassandra/db/ColumnFamilyStore.java |   12 +++---
 src/java/org/apache/cassandra/db/Memtable.java |   12 +++---
 .../apache/cassandra/db/commitlog/CommitLog.java   |   19 +++
 .../db/compaction/LeveledCompactionStrategy.java   |   25 +--
 .../cassandra/db/compaction/LeveledManifest.java   |9 +
 .../org/apache/cassandra/db/CommitLogTest.java |6 ++--
 7 files changed, 53 insertions(+), 32 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/cassandra/blob/08848e79/CHANGES.txt
--
diff --git a/CHANGES.txt b/CHANGES.txt
index f17ffd1..9246433 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 1.1.1-dev
+ * avoid blocking additional writes during flush when the commitlog
+   gets behind temporarily (CASSANDRA-1991)
  * enable caching on index CFs based on data CF cache setting (CASSANDRA-4197)
  * warn on invalid replication strategy creation options (CASSANDRA-4046)
  * remove [Freeable]Memory finalizers (CASSANDRA-4222)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/08848e79/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
--
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java 
b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 659be73..9dcf1ef 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -31,6 +31,7 @@ import java.util.regex.Pattern;
 import javax.management.*;
 
 import com.google.common.collect.*;
+import com.google.common.util.concurrent.Futures;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -609,8 +610,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 }
 
 assert getMemtableThreadSafe() == oldMemtable;
-final ReplayPosition ctx = writeCommitLog ? 
CommitLog.instance.getContext() : ReplayPosition.NONE;
-logger.debug(flush position is {}, ctx);
+final FutureReplayPosition ctx = writeCommitLog ? 
CommitLog.instance.getContext() : Futures.immediateFuture(ReplayPosition.NONE);
 
 // submit the memtable for any indexed sub-cfses, and our own.
 final ListColumnFamilyStore icc = new 
ArrayListColumnFamilyStore();
@@ -642,7 +642,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 // while keeping the wait-for-flush (future.get) out of anything 
latency-sensitive.
 return postFlushExecutor.submit(new WrappedRunnable()
 {
-public void runMayThrow() throws InterruptedException, 
IOException
+public void runMayThrow() throws InterruptedException, 
IOException, ExecutionException
 {
 latch.await();
 
@@ -662,7 +662,7 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 {
 // if we're not writing to the commit log, we are 
replaying the log, so marking
 // the log header with you can discard anything 
written before the context is not valid
-
CommitLog.instance.discardCompletedSegments(metadata.cfId, ctx);
+
CommitLog.instance.discardCompletedSegments(metadata.cfId, ctx.get());
 }
 }
 });
@@ -1710,13 +1710,13 @@ public class ColumnFamilyStore implements 
ColumnFamilyStoreMBean
 if (ksm.durableWrites)
 {
 CommitLog.instance.forceNewSegment();
-ReplayPosition position = CommitLog.instance.getContext();
+FutureReplayPosition position = CommitLog.instance.getContext();
 // now flush everyone else.  re-flushing ourselves is not 
necessary, but harmless
 for (ColumnFamilyStore cfs : ColumnFamilyStore.all())
 cfs.forceFlush();
 waitForActiveFlushes();
 // if everything was clean, flush won't have