cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/4] cassandra git commit: Fix setting 'durable_writes' in ALTER KEYSPACE
Date Wed, 01 Jul 2015 19:22:19 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 9627f13ef -> 067141a23


Fix setting 'durable_writes' in ALTER KEYSPACE

patch by Carl Yeksigian; reviewed by Aleksey Yeschenko for
CASSANDRA-9560


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

Branch: refs/heads/trunk
Commit: 3504a50bb4bd93edeb2941dccd9444d53a85a1ed
Parents: 0bdf923
Author: Carl Yeksigian <carl@apache.org>
Authored: Mon Jun 22 09:18:39 2015 -0400
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Wed Jul 1 21:47:07 2015 +0300

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../org/apache/cassandra/db/ColumnFamilyStore.java  |  2 +-
 src/java/org/apache/cassandra/db/DataTracker.java   |  2 +-
 src/java/org/apache/cassandra/db/DefsTables.java    |  2 +-
 src/java/org/apache/cassandra/db/Keyspace.java      | 16 +++++++++++++---
 src/java/org/apache/cassandra/db/RowMutation.java   |  2 +-
 .../unit/org/apache/cassandra/db/CommitLogTest.java |  2 +-
 7 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3504a50b/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2a69292..391874b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.17
+ * Fix setting 'durable_writes' in ALTER KEYSPACE (CASSANDRA-9560)
  * Avoid ballot clash in Paxos (CASSANDRA-9649)
  * Improve trace messages for RR (CASSANDRA-9479)
  * Fix suboptimal secondary index selection when restricted

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3504a50b/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 4fc2f24..bf1e779 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -2075,7 +2075,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         // position in the System keyspace.
         logger.debug("truncating {}", name);
 
-        if (keyspace.metadata.durableWrites || DatabaseDescriptor.isAutoSnapshot())
+        if (keyspace.getMetadata().durableWrites || DatabaseDescriptor.isAutoSnapshot())
         {
             // flush the CF being truncated before forcing the new segment
             forceBlockingFlush();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3504a50b/src/java/org/apache/cassandra/db/DataTracker.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DataTracker.java b/src/java/org/apache/cassandra/db/DataTracker.java
index f6d2c75..e961b77 100644
--- a/src/java/org/apache/cassandra/db/DataTracker.java
+++ b/src/java/org/apache/cassandra/db/DataTracker.java
@@ -130,7 +130,7 @@ public class DataTracker
      */
     public void renewMemtable()
     {
-        assert !cfstore.keyspace.metadata.durableWrites;
+        assert !cfstore.keyspace.getMetadata().durableWrites;
 
         Memtable newMemtable = new Memtable(cfstore);
         View currentView, newView;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3504a50b/src/java/org/apache/cassandra/db/DefsTables.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DefsTables.java b/src/java/org/apache/cassandra/db/DefsTables.java
index 35eecc0..f35d6a5 100644
--- a/src/java/org/apache/cassandra/db/DefsTables.java
+++ b/src/java/org/apache/cassandra/db/DefsTables.java
@@ -333,7 +333,7 @@ public class DefsTables
 
         if (!StorageService.instance.isClientMode())
         {
-            Keyspace.open(ksName).createReplicationStrategy(newKsm);
+            Keyspace.open(ksName).setMetadata(newKsm);
             MigrationManager.instance.notifyUpdateKeyspace(newKsm);
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3504a50b/src/java/org/apache/cassandra/db/Keyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Keyspace.java b/src/java/org/apache/cassandra/db/Keyspace.java
index 38b7c2b..915ccca 100644
--- a/src/java/org/apache/cassandra/db/Keyspace.java
+++ b/src/java/org/apache/cassandra/db/Keyspace.java
@@ -70,10 +70,9 @@ public class Keyspace
             DatabaseDescriptor.createAllDirectories();
     }
 
-    public final KSMetaData metadata;
-
     /* ColumnFamilyStore per column family */
     private final ConcurrentMap<UUID, ColumnFamilyStore> columnFamilyStores = new ConcurrentHashMap<UUID,
ColumnFamilyStore>();
+    private volatile KSMetaData metadata;
     private volatile AbstractReplicationStrategy replicationStrategy;
 
     public static final Function<String,Keyspace> keyspaceTransformer = new Function<String,
Keyspace>()
@@ -270,7 +269,7 @@ public class Keyspace
         }
     }
 
-    public void createReplicationStrategy(KSMetaData ksm)
+    private void createReplicationStrategy(KSMetaData ksm)
     {
         replicationStrategy = AbstractReplicationStrategy.createReplicationStrategy(ksm.name,
                                                                                     ksm.strategyClass,
@@ -279,6 +278,17 @@ public class Keyspace
                                                                                     ksm.strategyOptions);
     }
 
+    public void setMetadata(KSMetaData ksm)
+    {
+        this.metadata = ksm;
+        createReplicationStrategy(ksm);
+    }
+
+    public KSMetaData getMetadata()
+    {
+        return metadata;
+    }
+
     // best invoked on the compaction mananger.
     public void dropCf(UUID cfId)
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3504a50b/src/java/org/apache/cassandra/db/RowMutation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java
index 223225e..50bd014 100644
--- a/src/java/org/apache/cassandra/db/RowMutation.java
+++ b/src/java/org/apache/cassandra/db/RowMutation.java
@@ -208,7 +208,7 @@ public class RowMutation implements IMutation
     public void apply()
     {
         Keyspace ks = Keyspace.open(keyspaceName);
-        ks.apply(this, ks.metadata.durableWrites);
+        ks.apply(this, ks.getMetadata().durableWrites);
     }
 
     public void applyUnsafe()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3504a50b/test/unit/org/apache/cassandra/db/CommitLogTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CommitLogTest.java b/test/unit/org/apache/cassandra/db/CommitLogTest.java
index 38c192d..289fbc9 100644
--- a/test/unit/org/apache/cassandra/db/CommitLogTest.java
+++ b/test/unit/org/apache/cassandra/db/CommitLogTest.java
@@ -294,7 +294,7 @@ public class CommitLogTest extends SchemaLoader
         boolean prevAutoSnapshot = DatabaseDescriptor.isAutoSnapshot();
         DatabaseDescriptor.setAutoSnapshot(false);
         Keyspace notDurableKs = Keyspace.open("NoCommitlogSpace");
-        Assert.assertFalse(notDurableKs.metadata.durableWrites);
+        Assert.assertFalse(notDurableKs.getMetadata().durableWrites);
         ColumnFamilyStore cfs = notDurableKs.getColumnFamilyStore("Standard1");
         RowMutation rm;
         DecoratedKey dk = Util.dk("key1");


Mime
View raw message