cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r892891 - in /incubator/cassandra/branches/cassandra-0.5: CHANGES.txt src/java/org/apache/cassandra/service/CassandraServer.java src/java/org/apache/cassandra/service/ThriftValidation.java
Date Mon, 21 Dec 2009 17:28:58 GMT
Author: jbellis
Date: Mon Dec 21 17:28:57 2009
New Revision: 892891

URL: http://svn.apache.org/viewvc?rev=892891&view=rev
Log:
return an InvalidRequestException if a SlicePredicate does not specify exactly one of range
and column_names.  patch by jbellis; reviewed by Jonathan Hseu for CASSANDRA-643

Modified:
    incubator/cassandra/branches/cassandra-0.5/CHANGES.txt
    incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
    incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/ThriftValidation.java

Modified: incubator/cassandra/branches/cassandra-0.5/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.5/CHANGES.txt?rev=892891&r1=892890&r2=892891&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.5/CHANGES.txt (original)
+++ incubator/cassandra/branches/cassandra-0.5/CHANGES.txt Mon Dec 21 17:28:57 2009
@@ -11,6 +11,8 @@
    one or more nodes is down when the movement occurs (CASSANDRA-572)
  * Include dead nodes in gossip to avoid a variety of problems
    (CASSANDRA-634)
+ * return an InvalidRequestException for mal-formed SlicePredicates
+   (CASSANDRA-643)
 
 
 0.5.0 beta 2

Modified: incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java?rev=892891&r1=892890&r2=892891&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
(original)
+++ incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/CassandraServer.java
Mon Dec 21 17:28:57 2009
@@ -221,9 +221,9 @@
     throws InvalidRequestException, UnavailableException, TimedOutException
     {
         ThriftValidation.validateColumnParent(keyspace, column_parent);
-        List<ReadCommand> commands = new ArrayList<ReadCommand>();
-        SliceRange range = predicate.slice_range;
+        ThriftValidation.validatePredicate(keyspace, column_parent, predicate);
 
+        List<ReadCommand> commands = new ArrayList<ReadCommand>();
         if (predicate.column_names != null)
         {
             for (String key: keys)
@@ -231,16 +231,15 @@
                 ThriftValidation.validateKey(key);
                 commands.add(new SliceByNamesReadCommand(keyspace, key, column_parent, predicate.column_names));
             }
-            ThriftValidation.validateColumns(keyspace, column_parent, predicate.column_names);
         }
         else
         {
+            SliceRange range = predicate.slice_range;
             for (String key: keys)
             {
                 ThriftValidation.validateKey(key);
                 commands.add(new SliceFromReadCommand(keyspace, key, column_parent, range.start,
range.finish, range.reversed, range.count));
             }
-            ThriftValidation.validateRange(keyspace, column_parent, range);
         }
 
         return getSlice(commands, consistency_level);
@@ -556,10 +555,7 @@
     {
         if (logger.isDebugEnabled())
             logger.debug("range_slice");
-        if (predicate.getSlice_range() != null)
-            ThriftValidation.validateRange(keyspace, column_parent, predicate.getSlice_range());
-        else
-            ThriftValidation.validateColumns(keyspace, column_parent, predicate.getColumn_names());
+        ThriftValidation.validatePredicate(keyspace, column_parent, predicate);
         if (!StorageService.getPartitioner().preservesOrder())
         {
             throw new InvalidRequestException("range queries may only be performed against
an order-preserving partitioner");

Modified: incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/ThriftValidation.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/ThriftValidation.java?rev=892891&r1=892890&r2=892891&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/ThriftValidation.java
(original)
+++ incubator/cassandra/branches/cassandra-0.5/src/java/org/apache/cassandra/service/ThriftValidation.java
Mon Dec 21 17:28:57 2009
@@ -205,4 +205,18 @@
             throw new InvalidRequestException("range finish must come after start in the
order of traversal");
         }
     }
+
+    public static void validatePredicate(String keyspace, ColumnParent column_parent, SlicePredicate
predicate)
+            throws InvalidRequestException
+    {
+        if (predicate.column_names == null && predicate.slice_range == null)
+            throw new InvalidRequestException("predicate column_names and slice_range may
not both be null");
+        if (predicate.column_names != null && predicate.slice_range != null)
+            throw new InvalidRequestException("predicate column_names and slice_range may
not both be present");
+
+        if (predicate.getSlice_range() != null)
+            validateRange(keyspace, column_parent, predicate.slice_range);
+        else
+            validateColumns(keyspace, column_parent, predicate.column_names);
+    }
 }



Mime
View raw message