cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r961939 - /cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
Date Thu, 08 Jul 2010 21:12:11 GMT
Author: jbellis
Date: Thu Jul  8 21:12:11 2010
New Revision: 961939

URL: http://svn.apache.org/viewvc?rev=961939&view=rev
Log:
refactor doInsert to be used by batch_mutate as well as insert, batch_insert.  patch by jbellis

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

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=961939&r1=961938&r2=961939&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Thu Jul  8 21:12:11
2010
@@ -352,7 +352,7 @@ public class CassandraServer implements 
         {
             throw new InvalidRequestException(e.getMessage());
         }
-        doInsert(consistency_level, rm);
+        doInsert(consistency_level, Arrays.asList(rm));
     }
 
     public void batch_mutate(Map<byte[],Map<String,List<Mutation>>> mutation_map,
ConsistencyLevel consistency_level)
@@ -399,21 +399,8 @@ public class CassandraServer implements 
             }
             rowMutations.add(RowMutation.getRowMutationFromMutations(keySpace.get(), key,
columnFamilyToMutations));
         }
-        if (consistency_level == ConsistencyLevel.ZERO)
-        {
-            StorageProxy.mutate(rowMutations);
-        }
-        else
-        {
-            try 
-            {
-            	StorageProxy.mutateBlocking(rowMutations, consistency_level);
-            } 
-            catch (TimeoutException e) 
-            {
-            	throw new TimedOutException();
-            }
-        }
+
+        doInsert(consistency_level, rowMutations);
     }
 
     public void remove(byte[] key, ColumnPath column_path, Clock clock, ConsistencyLevel
consistency_level)
@@ -432,26 +419,26 @@ public class CassandraServer implements 
         RowMutation rm = new RowMutation(keySpace.get(), key);
         rm.delete(new QueryPath(column_path), cassandra_clock);
 
-        doInsert(consistency_level, rm);
+        doInsert(consistency_level, Arrays.asList(rm));
     }
 
-    private void doInsert(ConsistencyLevel consistency_level, RowMutation rm) throws UnavailableException,
TimedOutException
+    private void doInsert(ConsistencyLevel consistency_level, List<RowMutation> mutations)
throws UnavailableException, TimedOutException
     {
-        if (consistency_level != ConsistencyLevel.ZERO)
+        if (consistency_level == ConsistencyLevel.ZERO)
         {
-            try 
+            StorageProxy.mutate(mutations);
+        }
+        else
+        {
+            try
             {
-            	StorageProxy.mutateBlocking(Arrays.asList(rm), consistency_level);
+            	StorageProxy.mutateBlocking(mutations, consistency_level);
             }
             catch (TimeoutException e)
             {
             	throw new TimedOutException();
             }
         }
-        else
-        {
-            StorageProxy.mutate(Arrays.asList(rm));
-        }
     }
 
     public Map<String, Map<String, String>> describe_keyspace(String table) throws
NotFoundException



Mime
View raw message