cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r981999 - in /cassandra/trunk/src/java/org/apache/cassandra: service/StorageService.java thrift/CassandraServer.java
Date Tue, 03 Aug 2010 18:35:31 GMT
Author: gdusbabek
Date: Tue Aug  3 18:35:31 2010
New Revision: 981999

URL: http://svn.apache.org/viewvc?rev=981999&view=rev
Log:
complain if there aren't enough nodes to support requested RF. patch by gdusbabek, reviewed
by jbellis. CASSANDRA-1343

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=981999&r1=981998&r2=981999&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Tue Aug  3 18:35:31
2010
@@ -1679,8 +1679,16 @@ public class StorageService implements I
                 if (DatabaseDescriptor.getDefsVersion().timestamp() > 0 || Migration.getLastMigrationId()
!= null)
                     throw new ConfigurationException("Cannot load from XML on top of pre-existing
schemas.");
                 
+                Collection<KSMetaData> tables = DatabaseDescriptor.readTablesFromYaml();
+             
+                // cycle through first to make sure we can satisfy live nodes constraint.
+                int liveNodeCount = getLiveNodes().size();
+                for (KSMetaData table : tables)
+                    if (liveNodeCount < table.replicationFactor)
+                        throw new ConfigurationException("Not enough live nodes to support
this keyspace: " + table.name);
+                
                 Migration migration = null;
-                for (KSMetaData table : DatabaseDescriptor.readTablesFromYaml())
+                for (KSMetaData table : tables)
                 {
                     migration = new AddKeyspace(table); 
                     migration.apply();

Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=981999&r1=981998&r2=981999&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Tue Aug  3 18:35:31
2010
@@ -826,6 +826,9 @@ public class CassandraServer implements 
         if (!(DatabaseDescriptor.getAuthenticator() instanceof AllowAllAuthenticator))
             throw new InvalidRequestException("Unable to create new keyspace while authentication
is enabled.");
 
+        if (StorageService.instance.getLiveNodes().size() < ks_def.replication_factor)
+            throw new InvalidRequestException("Not enough live nodes to support this keyspace");
+        
         //generate a meaningful error if the user setup keyspace and/or column definition
incorrectly
         for (CfDef cf : ks_def.cf_defs) 
         {



Mime
View raw message