cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix stress for CQL3
Date Wed, 21 Nov 2012 16:25:09 GMT
Updated Branches:
  refs/heads/cassandra-1.2.0 a32eb9f7d -> e2df26b89


Fix stress for CQL3

patch by slebresne; reviewed by jbellis for CASSANDRA-4979


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

Branch: refs/heads/cassandra-1.2.0
Commit: e2df26b899d07edbacedd0a6722bc940fc48b65b
Parents: a32eb9f
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Nov 21 17:24:36 2012 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Nov 21 17:24:36 2012 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../src/org/apache/cassandra/stress/Session.java   |    2 +-
 .../org/apache/cassandra/stress/StressAction.java  |    1 -
 .../stress/operations/CqlCounterAdder.java         |   21 +++++++++----
 .../stress/operations/CqlCounterGetter.java        |   23 +++++++++------
 .../stress/operations/CqlIndexedRangeSlicer.java   |   18 +++++++++--
 .../cassandra/stress/operations/CqlInserter.java   |   19 +++++++++---
 .../stress/operations/CqlRangeSlicer.java          |   20 +++++++++----
 .../cassandra/stress/operations/CqlReader.java     |   17 ++++++++---
 9 files changed, 84 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 60e4c94..da74896 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -19,6 +19,7 @@
  * Remove select arbitrary limit (CASSANDRA-4918)
  * Correctly handle prepared operation on collections (CASSANDRA-4945)
  * Fix CQL3 LIMIT (CASSANDRA-4877)
+ * Fix Stress for CQL3 (CASSANDRA-4979)
 Merged from 1.1:
  * add basic authentication support for Pig CassandraStorage (CASSANDRA-3042)
  * fix CQL2 ALTER TABLE compaction_strategy_class altering (CASSANDRA-4965)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/Session.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/Session.java b/tools/stress/src/org/apache/cassandra/stress/Session.java
index 8b6914c..ac109a1 100644
--- a/tools/stress/src/org/apache/cassandra/stress/Session.java
+++ b/tools/stress/src/org/apache/cassandra/stress/Session.java
@@ -665,7 +665,7 @@ public class Session implements Serializable
             client.set_cql_version("3.0.0"); // just to create counter cf for cql3
 
             client.set_keyspace(KEYSPACE_NAME);
-            client.execute_cql_query(createCounterCFStatementForCQL3(), Compression.NONE);
+            client.execute_cql3_query(createCounterCFStatementForCQL3(), Compression.NONE,
ConsistencyLevel.ONE);
 
             if (enable_cql)
                 client.set_cql_version(cqlVersion);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/StressAction.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/StressAction.java b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
index 1227fe8..b5a7e6e 100644
--- a/tools/stress/src/org/apache/cassandra/stress/StressAction.java
+++ b/tools/stress/src/org/apache/cassandra/stress/StressAction.java
@@ -235,7 +235,6 @@ public class StressAction extends Thread
                         System.exit(-1);
                     }
 
-
                     output.println(e.getMessage());
                     returnCode = StressAction.FAILURE;
                     break;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
index 7ca4b0f..3dfd33e 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java
@@ -50,10 +50,12 @@ public class CqlCounterAdder extends Operation
         {
             String counterCF = session.cqlVersion.startsWith("2") ? "Counter1" : "Counter3";
 
-            StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired(counterCF))
-                                                              .append(" USING CONSISTENCY
")
-                                                              .append(session.getConsistencyLevel())
-                                                              .append(" SET ");
+            StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired(counterCF));
+
+            if (session.cqlVersion.startsWith("2"))
+                query.append(" USING CONSISTENCY ").append(session.getConsistencyLevel());
+
+            query.append(" SET ");
 
             for (int i = 0; i < session.getColumnsPerKey(); i++)
             {
@@ -84,14 +86,19 @@ public class CqlCounterAdder extends Operation
                 if (session.usePreparedStatements())
                 {
                     Integer stmntId = getPreparedStatement(client, cqlQuery);
-                    client.execute_prepared_cql_query(stmntId,
-                            Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))));
+                    if (session.cqlVersion.startsWith("3"))
+                        client.execute_prepared_cql3_query(stmntId, Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))),
session.getConsistencyLevel());
+                    else
+                        client.execute_prepared_cql_query(stmntId, Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))));
                 }
                 else
                 {
                     if (formattedQuery == null)
                         formattedQuery = formatCqlQuery(cqlQuery, Collections.singletonList(getUnQuotedCqlBlob(key)));
-                    client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
+                    if (session.cqlVersion.startsWith("3"))
+                        client.execute_cql3_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE, session.getConsistencyLevel());
+                    else
+                        client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
                 }
 
                 success = true;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
index 75a59ba..8b5a2bd 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java
@@ -59,12 +59,12 @@ public class CqlCounterGetter extends Operation
 
             String counterCF = session.cqlVersion.startsWith("2") ? "Counter1" : "Counter3";
 
-            query.append(" FROM ").append(wrapInQuotesIfRequired(counterCF))
-                                  .append(" USING CONSISTENCY ")
-                                  .append(session.getConsistencyLevel().toString())
-                                  .append(" WHERE KEY=?");
+            query.append(" FROM ").append(wrapInQuotesIfRequired(counterCF));
 
-            cqlQuery = query.toString();
+            if (session.cqlVersion.startsWith("2"))
+                query.append(" USING CONSISTENCY ").append(session.getConsistencyLevel().toString());
+
+            cqlQuery = query.append(" WHERE KEY=?").toString();
         }
 
         byte[] key = generateKey();
@@ -87,15 +87,20 @@ public class CqlCounterGetter extends Operation
                 if (session.usePreparedStatements())
                 {
                     Integer stmntId = getPreparedStatement(client, cqlQuery);
-                    result = client.execute_prepared_cql_query(stmntId,
-                            Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))));
+                    if (session.cqlVersion.startsWith("3"))
+                        result = client.execute_prepared_cql3_query(stmntId, Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))),
session.getConsistencyLevel());
+                    else
+                        result = client.execute_prepared_cql_query(stmntId, Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))));
                 }
                 else
                 {
                     if (formattedQuery == null)
                         formattedQuery = formatCqlQuery(cqlQuery, Collections.singletonList(getUnQuotedCqlBlob(key)));
-                    result = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
-                                                      Compression.NONE);
+
+                    if (session.cqlVersion.startsWith("3"))
+                        result = client.execute_cql3_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE, session.getConsistencyLevel());
+                    else
+                        result = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
                 }
 
                 assert result.type.equals(CqlResultType.ROWS) : "expected ROWS result type";

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
b/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
index 383ad67..66e626a 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
@@ -56,8 +56,12 @@ public class CqlIndexedRangeSlicer extends Operation
         if (cqlQuery == null)
         {
             StringBuilder query = new StringBuilder("SELECT FIRST ").append(session.getColumnsPerKey())
-                 .append(" ''..'' FROM Standard1 USING CONSISTENCY ").append(session.getConsistencyLevel())
-                 .append(" WHERE C1=").append(getUnQuotedCqlBlob(values.get(1).array()))
+                 .append(" ''..'' FROM Standard1");
+
+            if (session.cqlVersion.startsWith("2"))
+                query.append(" USING CONSISTENCY ").append(session.getConsistencyLevel());
+
+            query.append(" WHERE C1=").append(getUnQuotedCqlBlob(values.get(1).array()))
                  .append(" AND KEY > ? LIMIT ").append(session.getKeysPerCall());
 
             cqlQuery = query.toString();
@@ -88,13 +92,19 @@ public class CqlIndexedRangeSlicer extends Operation
                     if (session.usePreparedStatements())
                     {
                         Integer stmntId = getPreparedStatement(client, cqlQuery);
-                        results = client.execute_prepared_cql_query(stmntId, queryParamsAsByteBuffer(queryParms));
+                        if (session.cqlVersion.startsWith("3"))
+                            results = client.execute_prepared_cql3_query(stmntId, queryParamsAsByteBuffer(queryParms),
session.getConsistencyLevel());
+                        else
+                            results = client.execute_prepared_cql_query(stmntId, queryParamsAsByteBuffer(queryParms));
                     }
                     else
                     {
                         if (formattedQuery ==  null)
                             formattedQuery = formatCqlQuery(cqlQuery, queryParms);
-                        results = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
+                        if (session.cqlVersion.startsWith("3"))
+                            results = client.execute_cql3_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE, session.getConsistencyLevel());
+                        else
+                            results = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
                     }
 
                     success = (results.rows.size() != 0);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
index 25c42b0..aedf2de 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
@@ -54,9 +54,12 @@ public class CqlInserter extends Operation
         // Construct a query string once.
         if (cqlQuery == null)
         {
-            StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired("Standard1"))
-                    .append(" USING CONSISTENCY ")
-                    .append(session.getConsistencyLevel().toString()).append(" SET ");
+            StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired("Standard1"));
+
+            if (session.cqlVersion.startsWith("2"))
+                query.append(" USING CONSISTENCY ").append(session.getConsistencyLevel().toString());
+
+            query.append(" SET ");
 
             for (int i = 0; i < session.getColumnsPerKey(); i++)
             {
@@ -108,13 +111,19 @@ public class CqlInserter extends Operation
                 if (session.usePreparedStatements())
                 {
                     Integer stmntId = getPreparedStatement(client, cqlQuery);
-                    client.execute_prepared_cql_query(stmntId, queryParamsAsByteBuffer(queryParms));
+                    if (session.cqlVersion.startsWith("3"))
+                        client.execute_prepared_cql3_query(stmntId, queryParamsAsByteBuffer(queryParms),
session.getConsistencyLevel());
+                    else
+                        client.execute_prepared_cql_query(stmntId, queryParamsAsByteBuffer(queryParms));
                 }
                 else
                 {
                     if (formattedQuery == null)
                         formattedQuery = formatCqlQuery(cqlQuery, queryParms);
-                    client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
+                    if (session.cqlVersion.startsWith("3"))
+                        client.execute_cql3_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE, session.getConsistencyLevel());
+                    else
+                        client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
                 }
 
                 success = true;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
index 8b20867..5a59110 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
@@ -51,9 +51,12 @@ public class CqlRangeSlicer extends Operation
         if (cqlQuery == null)
         {
             StringBuilder query = new StringBuilder("SELECT FIRST ").append(session.getColumnsPerKey())
-                    .append(" ''..'' FROM Standard1 USING CONSISTENCY ").append(session.getConsistencyLevel().toString())
-                    .append(" WHERE KEY > ?");
-            cqlQuery = query.toString();
+                    .append(" ''..'' FROM Standard1");
+
+            if (session.cqlVersion.startsWith("2"))
+                query.append(" USING CONSISTENCY ").append(session.getConsistencyLevel().toString());
+
+            cqlQuery = query.append(" WHERE KEY > ?").toString();
         }
 
         String key = String.format("%0" +  session.getTotalKeysLength() + "d", index);
@@ -77,14 +80,19 @@ public class CqlRangeSlicer extends Operation
                 if (session.usePreparedStatements())
                 {
                     Integer stmntId = getPreparedStatement(client, cqlQuery);
-                    result = client.execute_prepared_cql_query(stmntId,
-                            Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))));
+                    if (session.cqlVersion.startsWith("3"))
+                        result = client.execute_prepared_cql3_query(stmntId, Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))),
session.getConsistencyLevel());
+                    else
+                        result = client.execute_prepared_cql_query(stmntId, Collections.singletonList(ByteBufferUtil.bytes(getUnQuotedCqlBlob(key))));
                 }
                 else
                 {
                     if (formattedQuery == null)
                         formattedQuery = formatCqlQuery(cqlQuery, Collections.singletonList(getUnQuotedCqlBlob(key)));
-                    result = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
+                    if (session.cqlVersion.startsWith("3"))
+                        result = client.execute_cql3_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE, session.getConsistencyLevel());
+                    else
+                        result = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
                 }
 
                 rowCount = result.rows.size();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e2df26b8/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
index ef43ae8..5e3259d 100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java
@@ -67,8 +67,10 @@ public class CqlReader extends Operation
                 }
             }
 
-            query.append(" FROM ").append(wrapInQuotesIfRequired("Standard1")).append(" USING
CONSISTENCY ")
-                 .append(session.getConsistencyLevel().toString());
+            query.append(" FROM ").append(wrapInQuotesIfRequired("Standard1"));
+
+            if (session.cqlVersion.startsWith("2"))
+                query.append(" USING CONSISTENCY ").append(session.getConsistencyLevel().toString());
             query.append(" WHERE KEY=?");
 
             cqlQuery = query.toString();
@@ -101,14 +103,19 @@ public class CqlReader extends Operation
                 if (session.usePreparedStatements())
                 {
                     Integer stmntId = getPreparedStatement(client, cqlQuery);
-                    result = client.execute_prepared_cql_query(stmntId, queryParamsAsByteBuffer(queryParams));
+                    if (session.cqlVersion.startsWith("3"))
+                        result = client.execute_prepared_cql3_query(stmntId, queryParamsAsByteBuffer(queryParams),
session.getConsistencyLevel());
+                    else
+                        result = client.execute_prepared_cql_query(stmntId, queryParamsAsByteBuffer(queryParams));
                 }
                 else
                 {
                     if (formattedQuery == null)
                         formattedQuery = formatCqlQuery(cqlQuery, queryParams);
-                    result = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
-                                                      Compression.NONE);
+                    if (session.cqlVersion.startsWith("3"))
+                        result = client.execute_cql3_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE, session.getConsistencyLevel());
+                    else
+                        result = client.execute_cql_query(ByteBuffer.wrap(formattedQuery.getBytes()),
Compression.NONE);
                 }
 
                 success = (result.rows.get(0).columns.size() != 0);


Mime
View raw message