cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject svn commit: r1165438 - in /cassandra/branches/cassandra-0.8: CHANGES.txt src/java/org/apache/cassandra/thrift/ThriftValidation.java test/unit/org/apache/cassandra/cli/CliTest.java test/unit/org/apache/cassandra/thrift/ThriftValidationTest.java
Date Mon, 05 Sep 2011 22:21:01 GMT
Author: xedin
Date: Mon Sep  5 22:21:01 2011
New Revision: 1165438

URL: http://svn.apache.org/viewvc?rev=1165438&view=rev
Log:
Prevent users from creating keyspaces with LocalStrategy replication
patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3139

Modified:
    cassandra/branches/cassandra-0.8/CHANGES.txt
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
    cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java
    cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/thrift/ThriftValidationTest.java

Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1165438&r1=1165437&r2=1165438&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Mon Sep  5 22:21:01 2011
@@ -1,7 +1,8 @@
 0.8.6
  * avoid trying to watch cassandra-topology.properties when loaded from jar
    (CASSANDRA-3138)
-
+ * prevent users from creating keyspaces with LocalStrategy replication
+   (CASSANDRA-3139)
 
 0.8.5
  * fix NPE when encryption_options is unspecified (CASSANDRA-3007)

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1165438&r1=1165437&r2=1165438&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
Mon Sep  5 22:21:01 2011
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.config.*;
+import org.apache.cassandra.locator.*;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.AsciiType;
@@ -36,10 +37,6 @@ import org.apache.cassandra.db.migration
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.RandomPartitioner;
 import org.apache.cassandra.dht.Token;
-import org.apache.cassandra.locator.AbstractReplicationStrategy;
-import org.apache.cassandra.locator.IEndpointSnitch;
-import org.apache.cassandra.locator.NetworkTopologyStrategy;
-import org.apache.cassandra.locator.TokenMetadata;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
@@ -671,6 +668,10 @@ public class ThriftValidation
         TokenMetadata tmd = StorageService.instance.getTokenMetadata();
         IEndpointSnitch eps = DatabaseDescriptor.getEndpointSnitch();
         Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ks_def.strategy_class);
+
+        if (cls.equals(LocalStrategy.class))
+            throw new ConfigurationException("Unable to use given strategy class: LocalStrategy
is reserved for internal use.");
+
         AbstractReplicationStrategy.createReplicationStrategy(ks_def.name, cls, tmd, eps,
options);
     }
 

Modified: cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java?rev=1165438&r1=1165437&r2=1165438&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java (original)
+++ cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/cli/CliTest.java Mon Sep
 5 22:21:01 2011
@@ -124,8 +124,7 @@ public class CliTest extends CleanupHelp
         "drop index on '123'.617070;",
         "drop index on '123'.'-617071';",
         "drop index on CF3.'big world';",
-        "update keyspace TestKeySpace with placement_strategy='org.apache.cassandra.locator.LocalStrategy'
and durable_writes = false;",
-        "update keyspace TestKeySpace with strategy_options=[{DC1:3, DC2:4, DC5:1}];",
+        "update keyspace TestKeySpace with durable_writes = false;",
         "assume 123 comparator as utf8;",
         "assume 123 sub_comparator as integer;",
         "assume 123 validator as lexicaluuid;",
@@ -166,6 +165,8 @@ public class CliTest extends CleanupHelp
         "get myCF['key']['scName']",
         "assume CF3 keys as utf8;",
         "use TestKEYSpace;",
+        "update keyspace TestKeySpace with placement_strategy='org.apache.cassandra.locator.NetworkTopologyStrategy';",
+        "update keyspace TestKeySpace with strategy_options=[{DC1:3, DC2:4, DC5:1}];",
         "describe cluster;",
         "help describe cluster;",
         "show cluster name",

Modified: cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/thrift/ThriftValidationTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/thrift/ThriftValidationTest.java?rev=1165438&r1=1165437&r2=1165438&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/thrift/ThriftValidationTest.java
(original)
+++ cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/thrift/ThriftValidationTest.java
Mon Sep  5 22:21:01 2011
@@ -28,17 +28,13 @@ import org.apache.cassandra.config.Datab
 import org.apache.cassandra.db.marshal.AsciiType;
 import org.apache.cassandra.db.marshal.UTF8Type;
 
-import org.junit.Test;
-
+import org.apache.cassandra.locator.LocalStrategy;
+import org.apache.cassandra.locator.NetworkTopologyStrategy;
 import org.apache.cassandra.CleanupHelper;
-import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.db.marshal.AsciiType;
-import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.utils.FBUtilities;
 
-import java.util.concurrent.Callable;
+import org.junit.Test;
 
 public class ThriftValidationTest extends CleanupHelper
 {
@@ -144,4 +140,56 @@ public class ThriftValidationTest extend
 
         assert gotException : "expected InvalidRequestException but not received.";
     }
+
+    @Test
+    public void testValidateKsDef()
+    {
+        KsDef ks_def = new KsDef()
+                            .setName("keyspaceValid")
+                            .setStrategy_class(LocalStrategy.class.getSimpleName());
+
+
+        boolean gotException = false;
+
+        try
+        {
+            ThriftValidation.validateKsDef(ks_def);
+        }
+        catch (ConfigurationException e)
+        {
+            gotException = true;
+        }
+
+        assert gotException : "expected ConfigurationException but not received.";
+
+        ks_def.setStrategy_class(LocalStrategy.class.getName());
+
+        gotException = false;
+
+        try
+        {
+            ThriftValidation.validateKsDef(ks_def);
+        }
+        catch (ConfigurationException e)
+        {
+            gotException = true;
+        }
+
+        assert gotException : "expected ConfigurationException but not received.";
+
+        ks_def.setStrategy_class(NetworkTopologyStrategy.class.getName());
+
+        gotException = false;
+
+        try
+        {
+            ThriftValidation.validateKsDef(ks_def);
+        }
+        catch (ConfigurationException e)
+        {
+            gotException = true;
+        }
+
+        assert !gotException : "got unexpected ConfigurationException";
+    }
 }



Mime
View raw message