mirror of https://github.com/apache/cassandra
Fix stress for CQL3
patch by slebresne; reviewed by jbellis for CASSANDRA-4979
This commit is contained in:
parent
a32eb9f7d2
commit
e2df26b899
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -235,7 +235,6 @@ public class StressAction extends Thread
|
|||
System.exit(-1);
|
||||
}
|
||||
|
||||
|
||||
output.println(e.getMessage());
|
||||
returnCode = StressAction.FAILURE;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue