cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/2] cassandra git commit: Test an NTS keyspace migration in LegacySchemaMigratorTest
Date Mon, 23 Nov 2015 20:24:14 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.1 e8737fda3 -> 383eb46b3


Test an NTS keyspace migration in LegacySchemaMigratorTest


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

Branch: refs/heads/cassandra-3.1
Commit: c7e74f349455bbdb6efd88e1b68a75ac1da83284
Parents: 0b3cfae
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Mon Nov 23 20:23:46 2015 +0000
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Nov 23 20:23:46 2015 +0000

----------------------------------------------------------------------
 .../org/apache/cassandra/schema/KeyspaceParams.java  |  5 +++++
 .../apache/cassandra/schema/ReplicationParams.java   | 15 +++++++++++++++
 .../cassandra/schema/LegacySchemaMigratorTest.java   |  3 +++
 3 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7e74f34/src/java/org/apache/cassandra/schema/KeyspaceParams.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/KeyspaceParams.java b/src/java/org/apache/cassandra/schema/KeyspaceParams.java
index 6cdf27f..c0e8916 100644
--- a/src/java/org/apache/cassandra/schema/KeyspaceParams.java
+++ b/src/java/org/apache/cassandra/schema/KeyspaceParams.java
@@ -69,6 +69,11 @@ public final class KeyspaceParams
         return new KeyspaceParams(false, ReplicationParams.simple(replicationFactor));
     }
 
+    public static KeyspaceParams nts(Object... args)
+    {
+        return new KeyspaceParams(true, ReplicationParams.nts(args));
+    }
+
     public void validate(String name)
     {
         replication.validate(name);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7e74f34/src/java/org/apache/cassandra/schema/ReplicationParams.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/schema/ReplicationParams.java b/src/java/org/apache/cassandra/schema/ReplicationParams.java
index cdeb4c2..21c029e 100644
--- a/src/java/org/apache/cassandra/schema/ReplicationParams.java
+++ b/src/java/org/apache/cassandra/schema/ReplicationParams.java
@@ -51,6 +51,21 @@ public final class ReplicationParams
         return new ReplicationParams(SimpleStrategy.class, ImmutableMap.of("replication_factor",
Integer.toString(replicationFactor)));
     }
 
+    static ReplicationParams nts(Object... args)
+    {
+        assert args.length % 2 == 0;
+
+        Map<String, String> options = new HashMap<>();
+        for (int i = 0; i < args.length; i += 2)
+        {
+            String dc = (String) args[i];
+            Integer rf = (Integer) args[i + 1];
+            options.put(dc, rf.toString());
+        }
+
+        return new ReplicationParams(NetworkTopologyStrategy.class, options);
+    }
+
     public void validate(String name)
     {
         // Attempt to instantiate the ARS, which will throw a ConfigurationException if the
options aren't valid.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7e74f34/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
index 7d0be4d..1ef3005 100644
--- a/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
+++ b/test/unit/org/apache/cassandra/schema/LegacySchemaMigratorTest.java
@@ -245,6 +245,9 @@ public class LegacySchemaMigratorTest
                                                                            + "PRIMARY KEY((bar,
baz), qux, quz) ) "
                                                                            + "WITH COMPACT
STORAGE", ks_cql))));
 
+        // NTS keyspace
+        keyspaces.add(KeyspaceMetadata.create("nts", KeyspaceParams.nts("dc1", 1, "dc2",
2)));
+
         keyspaces.add(keyspaceWithDroppedCollections());
         keyspaces.add(keyspaceWithTriggers());
         keyspaces.add(keyspaceWithUDTs());


Mime
View raw message