diff --git a/CHANGES.txt b/CHANGES.txt index 60e4c94ecd..da74896808 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) diff --git a/tools/stress/src/org/apache/cassandra/stress/Session.java b/tools/stress/src/org/apache/cassandra/stress/Session.java index 8b6914c849..ac109a1ece 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); diff --git a/tools/stress/src/org/apache/cassandra/stress/StressAction.java b/tools/stress/src/org/apache/cassandra/stress/StressAction.java index 1227fe8e60..b5a7e6e872 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; 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 7ca4b0fb4f..3dfd33e305 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; 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 75a59ba404..8b5a2bd661 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"; 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 383ad67e34..66e626a692 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); 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 25c42b03c1..aedf2de017 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; 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 8b20867398..5a59110915 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(); 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 ef43ae8690..5e3259d803 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);