cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [23/23] git commit: Merge branch 'cassandra-2.1' into trunk
Date Mon, 07 Jul 2014 17:34:46 GMT
Merge branch 'cassandra-2.1' into trunk

Conflicts:
	tools/stress/src/org/apache/cassandra/stress/Operation.java
	tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java
	tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java
	tools/stress/src/org/apache/cassandra/stress/operations/ThriftInserter.java
	tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterAdder.java
	tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterGetter.java
	tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlInserter.java
	tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlOperation.java
	tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlReader.java
	tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java


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

Branch: refs/heads/trunk
Commit: 047c04611bfdbb390ae51b092c1e23e510f82135
Parents: 8f76789 35b88c5
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Mon Jul 7 18:34:02 2014 +0100
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Mon Jul 7 18:34:02 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../cassandra/thrift/ThriftConversion.java      |  19 +
 .../org/apache/cassandra/utils/UUIDGen.java     |   8 +
 tools/bin/cassandra-stress                      |   2 +-
 tools/cqlstress-counter-example.yaml            |  85 +++
 tools/cqlstress-example.yaml                    |  99 +++
 tools/cqlstress-insanity-example.yaml           | 102 +++
 .../org/apache/cassandra/stress/Operation.java  | 214 +-----
 .../apache/cassandra/stress/StressAction.java   | 262 +++----
 .../apache/cassandra/stress/StressMetrics.java  |  17 +-
 .../apache/cassandra/stress/StressProfile.java  | 504 ++++++++++++++
 .../org/apache/cassandra/stress/StressYaml.java |  38 ++
 .../cassandra/stress/generate/Distribution.java |  57 ++
 .../generate/DistributionBoundApache.java       |  84 +++
 .../stress/generate/DistributionFactory.java    |  31 +
 .../stress/generate/DistributionFixed.java      |  54 ++
 .../stress/generate/DistributionInverted.java   |  37 +
 .../generate/DistributionOffsetApache.java      |  80 +++
 .../cassandra/stress/generate/Partition.java    | 343 ++++++++++
 .../stress/generate/PartitionGenerator.java     |  80 +++
 .../stress/generate/RatioDistribution.java      |  25 +
 .../generate/RatioDistributionFactory.java      |  31 +
 .../apache/cassandra/stress/generate/Row.java   |  22 +
 .../stress/generate/SeedGenerator.java          |   8 +
 .../stress/generate/SeedRandomGenerator.java    |  33 +
 .../stress/generate/SeedSeriesGenerator.java    |  21 +
 .../stress/generate/values/Booleans.java        |  37 +
 .../cassandra/stress/generate/values/Bytes.java |  54 ++
 .../cassandra/stress/generate/values/Dates.java |  46 ++
 .../stress/generate/values/Doubles.java         |  37 +
 .../stress/generate/values/Floats.java          |  37 +
 .../stress/generate/values/Generator.java       |  50 ++
 .../stress/generate/values/GeneratorConfig.java |  68 ++
 .../stress/generate/values/HexBytes.java        |  56 ++
 .../stress/generate/values/HexStrings.java      |  55 ++
 .../cassandra/stress/generate/values/Inets.java |  57 ++
 .../stress/generate/values/Integers.java        |  38 ++
 .../cassandra/stress/generate/values/Lists.java |  55 ++
 .../cassandra/stress/generate/values/Longs.java |  37 +
 .../cassandra/stress/generate/values/Sets.java  |  54 ++
 .../stress/generate/values/Strings.java         |  49 ++
 .../stress/generate/values/TimeUUIDs.java       |  51 ++
 .../cassandra/stress/generate/values/UUIDs.java |  39 ++
 .../cassandra/stress/generatedata/DataGen.java  |  39 --
 .../stress/generatedata/DataGenBytesRandom.java |  45 --
 .../stress/generatedata/DataGenFactory.java     |  30 -
 .../stress/generatedata/DataGenHex.java         |  60 --
 .../DataGenHexFromDistribution.java             |  66 --
 .../generatedata/DataGenHexFromOpIndex.java     |  48 --
 .../generatedata/DataGenStringDictionary.java   | 107 ---
 .../generatedata/DataGenStringRepeats.java      |  90 ---
 .../stress/generatedata/Distribution.java       |  40 --
 .../generatedata/DistributionBoundApache.java   |  63 --
 .../generatedata/DistributionFactory.java       |  31 -
 .../stress/generatedata/DistributionFixed.java  |  46 --
 .../generatedata/DistributionOffsetApache.java  |  61 --
 .../generatedata/DistributionSeqBatch.java      |  68 --
 .../cassandra/stress/generatedata/KeyGen.java   |  54 --
 .../cassandra/stress/generatedata/RowGen.java   |  53 --
 .../generatedata/RowGenDistributedSize.java     | 116 ----
 .../stress/operations/CqlCounterAdder.java      |  68 --
 .../stress/operations/CqlCounterGetter.java     |  59 --
 .../operations/CqlIndexedRangeSlicer.java       | 115 ----
 .../stress/operations/CqlInserter.java          |  87 ---
 .../stress/operations/CqlMultiGetter.java       |  42 --
 .../stress/operations/CqlOperation.java         | 658 ------------------
 .../stress/operations/CqlRangeSlicer.java       |  53 --
 .../cassandra/stress/operations/CqlReader.java  |  85 ---
 .../stress/operations/FixedOpDistribution.java  |  25 +
 .../stress/operations/OpDistribution.java       |  11 +
 .../operations/OpDistributionFactory.java       |  12 +
 .../operations/SampledOpDistribution.java       |  41 ++
 .../SampledOpDistributionFactory.java           |  72 ++
 .../stress/operations/ThriftCounterAdder.java   |  95 ---
 .../stress/operations/ThriftCounterGetter.java  |  68 --
 .../operations/ThriftIndexedRangeSlicer.java    | 114 ----
 .../stress/operations/ThriftInserter.java       | 119 ----
 .../stress/operations/ThriftMultiGetter.java    |  80 ---
 .../stress/operations/ThriftRangeSlicer.java    |  85 ---
 .../stress/operations/ThriftReader.java         |  94 ---
 .../operations/predefined/CqlCounterAdder.java  |  78 +++
 .../operations/predefined/CqlCounterGetter.java |  59 ++
 .../operations/predefined/CqlInserter.java      |  78 +++
 .../operations/predefined/CqlOperation.java     | 674 +++++++++++++++++++
 .../stress/operations/predefined/CqlReader.java |  81 +++
 .../predefined/PredefinedOperation.java         | 244 +++++++
 .../predefined/ThriftCounterAdder.java          |  86 +++
 .../predefined/ThriftCounterGetter.java         |  66 ++
 .../operations/predefined/ThriftInserter.java   |  98 +++
 .../operations/predefined/ThriftReader.java     |  79 +++
 .../operations/userdefined/SchemaInsert.java    | 144 ++++
 .../operations/userdefined/SchemaQuery.java     |  86 +++
 .../operations/userdefined/SchemaStatement.java | 164 +++++
 .../cassandra/stress/settings/Command.java      |  24 +-
 .../stress/settings/CommandCategory.java        |   4 +-
 .../stress/settings/OptionAnyProbabilities.java |  78 +++
 .../stress/settings/OptionDataGen.java          | 203 ------
 .../stress/settings/OptionDistribution.java     |  75 ++-
 .../settings/OptionEnumProbabilities.java       |  62 ++
 .../cassandra/stress/settings/OptionMulti.java  |   3 +-
 .../settings/OptionRatioDistribution.java       | 166 +++++
 .../cassandra/stress/settings/OptionSimple.java |   5 +-
 .../stress/settings/SettingsColumn.java         |  50 +-
 .../stress/settings/SettingsCommand.java        |  58 +-
 .../stress/settings/SettingsCommandMixed.java   | 207 ------
 .../settings/SettingsCommandPreDefined.java     | 145 ++++
 .../SettingsCommandPreDefinedMixed.java         | 151 +++++
 .../stress/settings/SettingsCommandUser.java    | 135 ++++
 .../cassandra/stress/settings/SettingsKey.java  |  27 +-
 .../cassandra/stress/settings/SettingsMisc.java |   2 +-
 .../cassandra/stress/settings/SettingsMode.java |   6 +-
 .../stress/settings/SettingsSchema.java         |  77 +--
 .../stress/settings/SettingsTransport.java      |   2 +-
 .../stress/settings/StressSettings.java         |  36 +-
 .../stress/settings/ValidationType.java         |   8 +
 .../cassandra/stress/util/JavaDriverClient.java |  19 +-
 .../stress/util/SmartThriftClient.java          |   4 +-
 .../org/apache/cassandra/stress/util/Timer.java |  17 +-
 .../cassandra/stress/util/TimingInterval.java   |  26 +-
 119 files changed, 5791 insertions(+), 3813 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/src/java/org/apache/cassandra/utils/UUIDGen.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterAdder.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterAdder.java
index 0000000,f794e75..2263e45
mode 000000,100644..100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterAdder.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterAdder.java
@@@ -1,0 -1,84 +1,78 @@@
+ package org.apache.cassandra.stress.operations.predefined;
+ /*
+  *
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  *
+  */
+ 
+ 
+ import java.nio.ByteBuffer;
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+ import org.apache.cassandra.stress.generate.Distribution;
+ import org.apache.cassandra.stress.generate.DistributionFactory;
+ import org.apache.cassandra.stress.generate.PartitionGenerator;
+ import org.apache.cassandra.stress.settings.Command;
+ import org.apache.cassandra.stress.settings.StressSettings;
+ import org.apache.cassandra.stress.util.Timer;
+ 
+ public class CqlCounterAdder extends CqlOperation<Integer>
+ {
+ 
+     final Distribution counteradd;
+     public CqlCounterAdder(DistributionFactory counteradd, Timer timer, PartitionGenerator generator, StressSettings settings)
+     {
+         super(Command.COUNTER_WRITE, timer, generator, settings);
+         this.counteradd = counteradd.get();
+     }
+ 
+     @Override
+     protected String buildQuery()
+     {
 -        String counterCF = isCql2() ? type.table : "Counter3";
 -
 -        StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired(counterCF));
 -
 -        if (isCql2())
 -            query.append(" USING CONSISTENCY ").append(settings.command.consistencyLevel);
 -
 -        query.append(" SET ");
++        StringBuilder query = new StringBuilder("UPDATE \"Counter3\" SET ");
+ 
+         // TODO : increment distribution subset of columns
+         for (int i = 0; i < settings.columns.maxColumnsPerKey; i++)
+         {
+             if (i > 0)
+                 query.append(",");
+ 
 -            query.append('C').append(i).append("=C").append(i).append("+?");
++            String name = settings.columns.namestrs.get(i);
++            query.append(name).append("=").append(name).append("+?");
+         }
+         query.append(" WHERE KEY=?");
+         return query.toString();
+     }
+ 
+     @Override
+     protected List<Object> getQueryParameters(byte[] key)
+     {
+         final List<Object> list = new ArrayList<>();
+         for (int i = 0; i < settings.columns.maxColumnsPerKey; i++)
+             list.add(counteradd.next());
+         list.add(ByteBuffer.wrap(key));
+         return list;
+     }
+ 
+     @Override
+     protected CqlRunOp<Integer> buildRunOp(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key)
+     {
+         return new CqlRunOpAlwaysSucceed(client, query, queryId, params, key, 1);
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterGetter.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterGetter.java
index 0000000,94c8faf..63f12c5
mode 000000,100644..100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterGetter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlCounterGetter.java
@@@ -1,0 -1,74 +1,59 @@@
+ package org.apache.cassandra.stress.operations.predefined;
+ /*
+  *
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  *
+  */
+ 
+ 
+ import java.nio.ByteBuffer;
+ import java.util.Collections;
+ import java.util.List;
+ 
+ import org.apache.cassandra.stress.generate.PartitionGenerator;
+ import org.apache.cassandra.stress.settings.Command;
+ import org.apache.cassandra.stress.settings.StressSettings;
+ import org.apache.cassandra.stress.util.Timer;
+ 
+ public class CqlCounterGetter extends CqlOperation<Integer>
+ {
+ 
+     public CqlCounterGetter(Timer timer, PartitionGenerator generator, StressSettings settings)
+     {
+         super(Command.COUNTER_READ, timer, generator, settings);
+     }
+ 
+     @Override
+     protected List<Object> getQueryParameters(byte[] key)
+     {
+         return Collections.<Object>singletonList(ByteBuffer.wrap(key));
+     }
+ 
+     @Override
+     protected String buildQuery()
+     {
 -        StringBuilder query = new StringBuilder("SELECT ");
 -
 -        // TODO: obey slice/noslice option (instead of always slicing)
 -        if (isCql2())
 -            query.append("FIRST ").append(settings.columns.maxColumnsPerKey).append(" ''..''");
 -        else
 -            query.append("*");
 -
 -        String counterCF = isCql2() ? type.table : "Counter3";
 -
 -        query.append(" FROM ").append(wrapInQuotesIfRequired(counterCF));
 -
 -        if (isCql2())
 -            query.append(" USING CONSISTENCY ").append(settings.command.consistencyLevel);
 -
 -        return query.append(" WHERE KEY=?").toString();
++        return "SELECT * FROM " + wrapInQuotes(type.table) + " WHERE KEY=?";
+     }
+ 
+     @Override
+     protected CqlRunOp<Integer> buildRunOp(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key)
+     {
+         return new CqlRunOpTestNonEmpty(client, query, queryId, params, key);
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlInserter.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlInserter.java
index 0000000,c422f2b..fc95b40
mode 000000,100644..100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlInserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlInserter.java
@@@ -1,0 -1,79 +1,78 @@@
+ package org.apache.cassandra.stress.operations.predefined;
+ /*
+  *
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  *
+  */
+ 
+ 
+ import java.nio.ByteBuffer;
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+ import org.apache.cassandra.stress.generate.PartitionGenerator;
+ import org.apache.cassandra.stress.settings.Command;
+ import org.apache.cassandra.stress.settings.StressSettings;
+ import org.apache.cassandra.stress.util.Timer;
+ import org.apache.cassandra.utils.UUIDGen;
+ 
+ public class CqlInserter extends CqlOperation<Integer>
+ {
+ 
+     public CqlInserter(Timer timer, PartitionGenerator generator, StressSettings settings)
+     {
+         super(Command.WRITE, timer, generator, settings);
+     }
+ 
+     @Override
+     protected String buildQuery()
+     {
 -        StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired(type.table));
 -
 -        if (isCql2())
 -            query.append(" USING CONSISTENCY ").append(settings.command.consistencyLevel);
++        StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotes(type.table));
++        if (settings.columns.timestamp != null)
++            query.append(" USING TIMESTAMP ").append(settings.columns.timestamp);
+ 
+         query.append(" SET ");
+ 
+         for (int i = 0 ; i < settings.columns.maxColumnsPerKey ; i++)
+         {
+             if (i > 0)
+                 query.append(',');
+ 
 -            query.append(wrapInQuotesIfRequired(settings.columns.namestrs.get(i))).append(" = ?");
++            query.append(wrapInQuotes(settings.columns.namestrs.get(i))).append(" = ?");
+         }
+ 
+         query.append(" WHERE KEY=?");
+         return query.toString();
+     }
+ 
+     @Override
+     protected List<Object> getQueryParameters(byte[] key)
+     {
+         final ArrayList<Object> queryParams = new ArrayList<>();
+         List<ByteBuffer> values = getColumnValues();
+         queryParams.addAll(values);
+         queryParams.add(ByteBuffer.wrap(key));
+         return queryParams;
+     }
+ 
+     @Override
+     protected CqlRunOp<Integer> buildRunOp(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key)
+     {
+         return new CqlRunOpAlwaysSucceed(client, query, queryId, params, key, 1);
+     }
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlOperation.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlOperation.java
index 0000000,0264cd1..318555e
mode 000000,100644..100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlOperation.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlOperation.java
@@@ -1,0 -1,714 +1,674 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  */
+ package org.apache.cassandra.stress.operations.predefined;
+ 
+ import java.io.IOException;
+ import java.nio.ByteBuffer;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import java.util.List;
+ 
+ import com.datastax.driver.core.PreparedStatement;
+ import com.datastax.driver.core.ResultSet;
+ import com.datastax.driver.core.Row;
+ import com.google.common.base.Function;
+ import org.apache.cassandra.stress.Operation;
+ import org.apache.cassandra.stress.StressMetrics;
+ import org.apache.cassandra.stress.generate.PartitionGenerator;
+ import org.apache.cassandra.stress.settings.Command;
+ import org.apache.cassandra.stress.settings.ConnectionStyle;
+ import org.apache.cassandra.stress.settings.CqlVersion;
+ import org.apache.cassandra.stress.settings.StressSettings;
+ import org.apache.cassandra.stress.util.JavaDriverClient;
+ import org.apache.cassandra.stress.util.ThriftClient;
+ import org.apache.cassandra.stress.util.Timer;
+ import org.apache.cassandra.thrift.Compression;
+ import org.apache.cassandra.thrift.CqlResult;
+ import org.apache.cassandra.thrift.CqlRow;
+ import org.apache.cassandra.thrift.ThriftConversion;
+ import org.apache.cassandra.transport.SimpleClient;
+ import org.apache.cassandra.transport.messages.ResultMessage;
+ import org.apache.cassandra.utils.ByteBufferUtil;
+ import org.apache.thrift.TException;
+ 
+ public abstract class CqlOperation<V> extends PredefinedOperation
+ {
+ 
+     protected abstract List<Object> getQueryParameters(byte[] key);
+     protected abstract String buildQuery();
+     protected abstract CqlRunOp<V> buildRunOp(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key);
+ 
+     public CqlOperation(Command type, Timer timer, PartitionGenerator generator, StressSettings settings)
+     {
+         super(type, timer, generator, settings);
+         if (settings.columns.variableColumnCount)
+             throw new IllegalStateException("Variable column counts are not implemented for CQL");
+     }
+ 
+     protected CqlRunOp<V> run(final ClientWrapper client, final List<Object> queryParams, final ByteBuffer key) throws IOException
+     {
+         final CqlRunOp<V> op;
+         if (settings.mode.style == ConnectionStyle.CQL_PREPARED)
+         {
+             final Object id;
+             Object idobj = getCqlCache();
+             if (idobj == null)
+             {
+                 try
+                 {
+                     id = client.createPreparedStatement(buildQuery());
+                 } catch (TException e)
+                 {
+                     throw new RuntimeException(e);
+                 }
+                 storeCqlCache(id);
+             }
+             else
+                 id = idobj;
+ 
+             op = buildRunOp(client, null, id, queryParams, key);
+         }
+         else
+         {
+             final String query;
+             Object qobj = getCqlCache();
+             if (qobj == null)
+                 storeCqlCache(query = buildQuery());
+             else
+                 query = qobj.toString();
+ 
+             op = buildRunOp(client, query, null, queryParams, key);
+         }
+ 
+         timeWithRetry(op);
+         return op;
+     }
+ 
+     protected void run(final ClientWrapper client) throws IOException
+     {
+         final byte[] key = getKey().array();
+         final List<Object> queryParams = getQueryParameters(key);
+         run(client, queryParams, ByteBuffer.wrap(key));
+     }
+ 
+     // Classes to process Cql results
+ 
+     // Always succeeds so long as the query executes without error; provides a keyCount to increment on instantiation
+     protected final class CqlRunOpAlwaysSucceed extends CqlRunOp<Integer>
+     {
+ 
+         final int keyCount;
+ 
+         protected CqlRunOpAlwaysSucceed(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key, int keyCount)
+         {
+             super(client, query, queryId, RowCountHandler.INSTANCE, params, key);
+             this.keyCount = keyCount;
+         }
+ 
+         @Override
+         public boolean validate(Integer result)
+         {
+             return true;
+         }
+ 
+         @Override
+         public int partitionCount()
+         {
+             return keyCount;
+         }
+ 
+         @Override
+         public int rowCount()
+         {
+             return keyCount;
+         }
+     }
+ 
+     // Succeeds so long as the result set is nonempty, and the query executes without error
+     protected final class CqlRunOpTestNonEmpty extends CqlRunOp<Integer>
+     {
+ 
+         protected CqlRunOpTestNonEmpty(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key)
+         {
+             super(client, query, queryId, RowCountHandler.INSTANCE, params, key);
+         }
+ 
+         @Override
+         public boolean validate(Integer result)
+         {
+             return result > 0;
+         }
+ 
+         @Override
+         public int partitionCount()
+         {
+             return result;
+         }
+ 
+         @Override
+         public int rowCount()
+         {
+             return result;
+         }
+     }
+ 
+     // Requires a custom validate() method, but fetches and stores the keys from the result set for further processing
+     protected abstract class CqlRunOpFetchKeys extends CqlRunOp<byte[][]>
+     {
+ 
+         protected CqlRunOpFetchKeys(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key)
+         {
+             super(client, query, queryId, KeysHandler.INSTANCE, params, key);
+         }
+ 
+         @Override
+         public int partitionCount()
+         {
+             return result.length;
+         }
+ 
+         @Override
+         public int rowCount()
+         {
+             return result.length;
+         }
+     }
+ 
+     protected final class CqlRunOpMatchResults extends CqlRunOp<ByteBuffer[][]>
+     {
+ 
+         final List<List<ByteBuffer>> expect;
+ 
+         // a null value for an item in expect means we just check the row is present
+         protected CqlRunOpMatchResults(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key, List<List<ByteBuffer>> expect)
+         {
+             super(client, query, queryId, RowsHandler.INSTANCE, params, key);
+             this.expect = expect;
+         }
+ 
+         @Override
+         public int partitionCount()
+         {
+             return result == null ? 0 : result.length;
+         }
+ 
+         @Override
+         public int rowCount()
+         {
+             return result == null ? 0 : result.length;
+         }
+ 
+         public boolean validate(ByteBuffer[][] result)
+         {
+             if (result.length != expect.size())
+                 return false;
+             for (int i = 0 ; i < result.length ; i++)
+                 if (expect.get(i) != null && !expect.get(i).equals(Arrays.asList(result[i])))
+                     return false;
+             return true;
+         }
+     }
+ 
+     // Cql
+     protected abstract class CqlRunOp<V> implements RunOp
+     {
+ 
+         final ClientWrapper client;
+         final String query;
+         final Object queryId;
+         final List<Object> params;
+         final ByteBuffer key;
+         final ResultHandler<V> handler;
+         V result;
+ 
+         private CqlRunOp(ClientWrapper client, String query, Object queryId, ResultHandler<V> handler, List<Object> params, ByteBuffer key)
+         {
+             this.client = client;
+             this.query = query;
+             this.queryId = queryId;
+             this.handler = handler;
+             this.params = params;
+             this.key = key;
+         }
+ 
+         @Override
+         public boolean run() throws Exception
+         {
+             return queryId != null
+             ? validate(result = client.execute(queryId, key, params, handler))
+             : validate(result = client.execute(query, key, params, handler));
+         }
+ 
+         public abstract boolean validate(V result);
+ 
+     }
+ 
+ 
+     /// LOTS OF WRAPPING/UNWRAPPING NONSENSE
+ 
+ 
+     @Override
+     public void run(final ThriftClient client) throws IOException
+     {
+         run(wrap(client));
+     }
+ 
+     @Override
+     public void run(SimpleClient client) throws IOException
+     {
+         run(wrap(client));
+     }
+ 
+     @Override
+     public void run(JavaDriverClient client) throws IOException
+     {
+         run(wrap(client));
+     }
+ 
+     public ClientWrapper wrap(ThriftClient client)
+     {
 -        return isCql3()
 -                ? new Cql3CassandraClientWrapper(client)
 -                : new Cql2CassandraClientWrapper(client);
 -
++        return new Cql3CassandraClientWrapper(client);
+     }
+ 
+     public ClientWrapper wrap(JavaDriverClient client)
+     {
+         return new JavaDriverWrapper(client);
+     }
+ 
+     public ClientWrapper wrap(SimpleClient client)
+     {
+         return new SimpleClientWrapper(client);
+     }
+ 
+     protected interface ClientWrapper
+     {
+         Object createPreparedStatement(String cqlQuery) throws TException;
+         <V> V execute(Object preparedStatementId, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler) throws TException;
+         <V> V execute(String query, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler) throws TException;
+     }
+ 
+     private final class JavaDriverWrapper implements ClientWrapper
+     {
+         final JavaDriverClient client;
+         private JavaDriverWrapper(JavaDriverClient client)
+         {
+             this.client = client;
+         }
+ 
+         @Override
+         public <V> V execute(String query, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler)
+         {
 -            String formattedQuery = formatCqlQuery(query, queryParams, isCql3());
++            String formattedQuery = formatCqlQuery(query, queryParams);
+             return handler.javaDriverHandler().apply(client.execute(formattedQuery, ThriftConversion.fromThrift(settings.command.consistencyLevel)));
+         }
+ 
+         @Override
+         public <V> V execute(Object preparedStatementId, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler)
+         {
+             return handler.javaDriverHandler().apply(
+                     client.executePrepared(
+                             (PreparedStatement) preparedStatementId,
+                             queryParams,
+                             ThriftConversion.fromThrift(settings.command.consistencyLevel)));
+         }
+ 
+         @Override
+         public Object createPreparedStatement(String cqlQuery)
+         {
+             return client.prepare(cqlQuery);
+         }
+     }
+ 
+     private final class SimpleClientWrapper implements ClientWrapper
+     {
+         final SimpleClient client;
+         private SimpleClientWrapper(SimpleClient client)
+         {
+             this.client = client;
+         }
+ 
+         @Override
+         public <V> V execute(String query, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler)
+         {
 -            String formattedQuery = formatCqlQuery(query, queryParams, isCql3());
++            String formattedQuery = formatCqlQuery(query, queryParams);
+             return handler.thriftHandler().apply(client.execute(formattedQuery, ThriftConversion.fromThrift(settings.command.consistencyLevel)));
+         }
+ 
+         @Override
+         public <V> V execute(Object preparedStatementId, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler)
+         {
+             return handler.thriftHandler().apply(
+                     client.executePrepared(
+                             (byte[]) preparedStatementId,
+                             toByteBufferParams(queryParams),
+                             ThriftConversion.fromThrift(settings.command.consistencyLevel)));
+         }
+ 
+         @Override
+         public Object createPreparedStatement(String cqlQuery)
+         {
+             return client.prepare(cqlQuery).statementId.bytes;
+         }
+     }
+ 
+     // client wrapper for Cql3
+     private final class Cql3CassandraClientWrapper implements ClientWrapper
+     {
+         final ThriftClient client;
+         private Cql3CassandraClientWrapper(ThriftClient client)
+         {
+             this.client = client;
+         }
+ 
+         @Override
+         public <V> V execute(String query, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler) throws TException
+         {
 -            String formattedQuery = formatCqlQuery(query, queryParams, true);
++            String formattedQuery = formatCqlQuery(query, queryParams);
+             return handler.simpleNativeHandler().apply(
+                     client.execute_cql3_query(formattedQuery, key, Compression.NONE, settings.command.consistencyLevel)
+             );
+         }
+ 
+         @Override
+         public <V> V execute(Object preparedStatementId, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler) throws TException
+         {
+             Integer id = (Integer) preparedStatementId;
+             return handler.simpleNativeHandler().apply(
+                     client.execute_prepared_cql3_query(id, key, toByteBufferParams(queryParams), settings.command.consistencyLevel)
+             );
+         }
+ 
+         @Override
+         public Object createPreparedStatement(String cqlQuery) throws TException
+         {
+             return client.prepare_cql3_query(cqlQuery, Compression.NONE);
+         }
+     }
+ 
 -    // client wrapper for Cql2
 -    private final class Cql2CassandraClientWrapper implements ClientWrapper
 -    {
 -        final ThriftClient client;
 -        private Cql2CassandraClientWrapper(ThriftClient client)
 -        {
 -            this.client = client;
 -        }
 -
 -        @Override
 -        public <V> V execute(String query, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler) throws TException
 -        {
 -            String formattedQuery = formatCqlQuery(query, queryParams, false);
 -            return handler.simpleNativeHandler().apply(
 -                    client.execute_cql_query(formattedQuery, key, Compression.NONE)
 -            );
 -        }
 -
 -        @Override
 -        public <V> V execute(Object preparedStatementId, ByteBuffer key, List<Object> queryParams, ResultHandler<V> handler) throws TException
 -        {
 -            Integer id = (Integer) preparedStatementId;
 -            return handler.simpleNativeHandler().apply(
 -                    client.execute_prepared_cql_query(id, key, toByteBufferParams(queryParams))
 -            );
 -        }
 -
 -        @Override
 -        public Object createPreparedStatement(String cqlQuery) throws TException
 -        {
 -            return client.prepare_cql_query(cqlQuery, Compression.NONE);
 -        }
 -    }
 -
+     // interface for building functions to standardise results from each client
+     protected static interface ResultHandler<V>
+     {
+         Function<ResultSet, V> javaDriverHandler();
+         Function<ResultMessage, V> thriftHandler();
+         Function<CqlResult, V> simpleNativeHandler();
+     }
+ 
+     protected static class RowCountHandler implements ResultHandler<Integer>
+     {
+         static final RowCountHandler INSTANCE = new RowCountHandler();
+ 
+         @Override
+         public Function<ResultSet, Integer> javaDriverHandler()
+         {
+             return new Function<ResultSet, Integer>()
+             {
+                 @Override
+                 public Integer apply(ResultSet rows)
+                 {
+                     if (rows == null)
+                         return 0;
+                     return rows.all().size();
+                 }
+             };
+         }
+ 
+         @Override
+         public Function<ResultMessage, Integer> thriftHandler()
+         {
+             return new Function<ResultMessage, Integer>()
+             {
+                 @Override
+                 public Integer apply(ResultMessage result)
+                 {
+                     return result instanceof ResultMessage.Rows ? ((ResultMessage.Rows) result).result.size() : 0;
+                 }
+             };
+         }
+ 
+         @Override
+         public Function<CqlResult, Integer> simpleNativeHandler()
+         {
+             return new Function<CqlResult, Integer>()
+             {
+ 
+                 @Override
+                 public Integer apply(CqlResult result)
+                 {
+                     switch (result.getType())
+                     {
+                         case ROWS:
+                             return result.getRows().size();
+                         default:
+                             return 1;
+                     }
+                 }
+             };
+         }
+ 
+     }
+ 
+     // Processes results from each client into an array of all key bytes returned
+     protected static final class RowsHandler implements ResultHandler<ByteBuffer[][]>
+     {
+         static final RowsHandler INSTANCE = new RowsHandler();
+ 
+         @Override
+         public Function<ResultSet, ByteBuffer[][]> javaDriverHandler()
+         {
+             return new Function<ResultSet, ByteBuffer[][]>()
+             {
+ 
+                 @Override
+                 public ByteBuffer[][] apply(ResultSet result)
+                 {
+                     if (result == null)
+                         return new ByteBuffer[0][];
+                     List<Row> rows = result.all();
+ 
+                     ByteBuffer[][] r = new ByteBuffer[rows.size()][];
+                     for (int i = 0 ; i < r.length ; i++)
+                     {
+                         Row row = rows.get(i);
+                         r[i] = new ByteBuffer[row.getColumnDefinitions().size()];
+                         for (int j = 0 ; j < row.getColumnDefinitions().size() ; j++)
+                             r[i][j] = row.getBytes(j);
+                     }
+                     return r;
+                 }
+             };
+         }
+ 
+         @Override
+         public Function<ResultMessage, ByteBuffer[][]> thriftHandler()
+         {
+             return new Function<ResultMessage, ByteBuffer[][]>()
+             {
+ 
+                 @Override
+                 public ByteBuffer[][] apply(ResultMessage result)
+                 {
+                     if (!(result instanceof ResultMessage.Rows))
+                         return new ByteBuffer[0][];
+ 
+                     ResultMessage.Rows rows = ((ResultMessage.Rows) result);
+                     ByteBuffer[][] r = new ByteBuffer[rows.result.size()][];
+                     for (int i = 0 ; i < r.length ; i++)
+                     {
+                         List<ByteBuffer> row = rows.result.rows.get(i);
+                         r[i] = new ByteBuffer[row.size()];
+                         for (int j = 0 ; j < row.size() ; j++)
+                             r[i][j] = row.get(j);
+                     }
+                     return r;
+                 }
+             };
+         }
+ 
+         @Override
+         public Function<CqlResult, ByteBuffer[][]> simpleNativeHandler()
+         {
+             return new Function<CqlResult, ByteBuffer[][]>()
+             {
+ 
+                 @Override
+                 public ByteBuffer[][] apply(CqlResult result)
+                 {
+                     ByteBuffer[][] r = new ByteBuffer[result.getRows().size()][];
+                     for (int i = 0 ; i < r.length ; i++)
+                     {
+                         CqlRow row = result.getRows().get(i);
+                         r[i] = new ByteBuffer[row.getColumns().size()];
+                         for (int j = 0 ; j < r[i].length ; j++)
+                             r[i][j] = ByteBuffer.wrap(row.getColumns().get(j).getValue());
+                     }
+                     return r;
+                 }
+             };
+         }
+ 
+     }
+     // Processes results from each client into an array of all key bytes returned
+     protected static final class KeysHandler implements ResultHandler<byte[][]>
+     {
+         static final KeysHandler INSTANCE = new KeysHandler();
+ 
+         @Override
+         public Function<ResultSet, byte[][]> javaDriverHandler()
+         {
+             return new Function<ResultSet, byte[][]>()
+             {
+ 
+                 @Override
+                 public byte[][] apply(ResultSet result)
+                 {
+ 
+                     if (result == null)
+                         return new byte[0][];
+                     List<Row> rows = result.all();
+                     byte[][] r = new byte[rows.size()][];
+                     for (int i = 0 ; i < r.length ; i++)
+                         r[i] = rows.get(i).getBytes(0).array();
+                     return r;
+                 }
+             };
+         }
+ 
+         @Override
+         public Function<ResultMessage, byte[][]> thriftHandler()
+         {
+             return new Function<ResultMessage, byte[][]>()
+             {
+ 
+                 @Override
+                 public byte[][] apply(ResultMessage result)
+                 {
+                     if (result instanceof ResultMessage.Rows)
+                     {
+                         ResultMessage.Rows rows = ((ResultMessage.Rows) result);
+                         byte[][] r = new byte[rows.result.size()][];
+                         for (int i = 0 ; i < r.length ; i++)
+                             r[i] = rows.result.rows.get(i).get(0).array();
+                         return r;
+                     }
+                     return null;
+                 }
+             };
+         }
+ 
+         @Override
+         public Function<CqlResult, byte[][]> simpleNativeHandler()
+         {
+             return new Function<CqlResult, byte[][]>()
+             {
+ 
+                 @Override
+                 public byte[][] apply(CqlResult result)
+                 {
+                     byte[][] r = new byte[result.getRows().size()][];
+                     for (int i = 0 ; i < r.length ; i++)
+                         r[i] = result.getRows().get(i).getKey();
+                     return r;
+                 }
+             };
+         }
+ 
+     }
+ 
 -    private static String getUnQuotedCqlBlob(ByteBuffer term, boolean isCQL3)
++    private static String getUnQuotedCqlBlob(ByteBuffer term)
+     {
 -        return isCQL3
 -                ? "0x" + ByteBufferUtil.bytesToHex(term)
 -                : ByteBufferUtil.bytesToHex(term);
++        return "0x" + ByteBufferUtil.bytesToHex(term);
+     }
+ 
+     /**
+      * Constructs a CQL query string by replacing instances of the character
+      * '?', with the corresponding parameter.
+      *
+      * @param query base query string to format
+      * @param parms sequence of string query parameters
+      * @return formatted CQL query string
+      */
 -    private static String formatCqlQuery(String query, List<Object> parms, boolean isCql3)
++    private static String formatCqlQuery(String query, List<Object> parms)
+     {
+         int marker, position = 0;
+         StringBuilder result = new StringBuilder();
+ 
+         if (-1 == (marker = query.indexOf('?')) || parms.size() == 0)
+             return query;
+ 
+         for (Object parm : parms)
+         {
+             result.append(query.substring(position, marker));
++
+             if (parm instanceof ByteBuffer)
 -                result.append(getUnQuotedCqlBlob((ByteBuffer) parm, isCql3));
++                result.append(getUnQuotedCqlBlob((ByteBuffer) parm));
+             else if (parm instanceof Long)
+                 result.append(parm.toString());
+             else throw new AssertionError();
+ 
+             position = marker + 1;
+             if (-1 == (marker = query.indexOf('?', position + 1)))
+                 break;
+         }
+ 
+         if (position < query.length())
+             result.append(query.substring(position));
+ 
+         return result.toString();
+     }
+ 
+     private static List<ByteBuffer> toByteBufferParams(List<Object> params)
+     {
+         List<ByteBuffer> r = new ArrayList<>();
+         for (Object param : params)
+         {
+             if (param instanceof ByteBuffer)
+                 r.add((ByteBuffer) param);
+             else if (param instanceof Long)
+                 r.add(ByteBufferUtil.bytes((Long) param));
+             else throw new AssertionError();
+         }
+         return r;
+     }
+ 
 -    protected String wrapInQuotesIfRequired(String string)
++    protected String wrapInQuotes(String string)
+     {
 -        return settings.mode.cqlVersion == CqlVersion.CQL3
 -                ? "\"" + string + "\""
 -                : string;
++        return "\"" + string + "\"";
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlReader.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlReader.java
index 0000000,3a7f75a..b06d866
mode 000000,100644..100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlReader.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/CqlReader.java
@@@ -1,0 -1,87 +1,81 @@@
+ package org.apache.cassandra.stress.operations.predefined;
+ /*
+  *
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *   http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing,
+  * software distributed under the License is distributed on an
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  * KIND, either express or implied.  See the License for the
+  * specific language governing permissions and limitations
+  * under the License.
+  *
+  */
+ 
+ 
+ import java.nio.ByteBuffer;
+ import java.nio.charset.CharacterCodingException;
+ import java.util.Arrays;
+ import java.util.Collections;
+ import java.util.List;
+ 
+ import org.apache.cassandra.stress.generate.PartitionGenerator;
+ import org.apache.cassandra.stress.settings.Command;
+ import org.apache.cassandra.stress.settings.StressSettings;
+ import org.apache.cassandra.stress.util.Timer;
+ import org.apache.cassandra.utils.ByteBufferUtil;
+ 
+ public class CqlReader extends CqlOperation<ByteBuffer[][]>
+ {
+ 
+     public CqlReader(Timer timer, PartitionGenerator generator, StressSettings settings)
+     {
+         super(Command.READ, timer, generator, settings);
+     }
+ 
+     @Override
+     protected String buildQuery()
+     {
+         StringBuilder query = new StringBuilder("SELECT ");
+ 
+         if (settings.columns.slice)
+         {
 -            if (isCql2())
 -                query.append("FIRST ").append(settings.columns.maxColumnsPerKey).append(" ''..''");
 -            else
 -                query.append("*");
++            query.append("*");
+         }
+         else
+         {
+             for (int i = 0; i < settings.columns.maxColumnsPerKey ; i++)
+             {
+                 if (i > 0)
+                     query.append(",");
 -                query.append(wrapInQuotesIfRequired(settings.columns.namestrs.get(i)));
++                query.append(wrapInQuotes(settings.columns.namestrs.get(i)));
+             }
+         }
+ 
 -        query.append(" FROM ").append(wrapInQuotesIfRequired(type.table));
 -
 -        if (isCql2())
 -            query.append(" USING CONSISTENCY ").append(settings.command.consistencyLevel);
++        query.append(" FROM ").append(wrapInQuotes(type.table));
+         query.append(" WHERE KEY=?");
+         return query.toString();
+     }
+ 
+     @Override
+     protected List<Object> getQueryParameters(byte[] key)
+     {
+         return Collections.<Object>singletonList(ByteBuffer.wrap(key));
+     }
+ 
+     @Override
+     protected CqlRunOp<ByteBuffer[][]> buildRunOp(ClientWrapper client, String query, Object queryId, List<Object> params, ByteBuffer key)
+     {
+         List<ByteBuffer> expectRow = getColumnValues();
+         return new CqlRunOpMatchResults(client, query, queryId, params, key, Arrays.asList(expectRow));
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/operations/predefined/PredefinedOperation.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/operations/predefined/PredefinedOperation.java
index 0000000,7f6412b..06bcfd6
mode 000000,100644..100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/PredefinedOperation.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/PredefinedOperation.java
@@@ -1,0 -1,248 +1,244 @@@
+ /**
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package org.apache.cassandra.stress.operations.predefined;
+ 
+ import java.nio.ByteBuffer;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import java.util.Collections;
+ import java.util.EnumMap;
+ import java.util.List;
+ import java.util.concurrent.ThreadLocalRandom;
+ 
+ import org.apache.cassandra.stress.Operation;
+ import org.apache.cassandra.stress.StressMetrics;
+ import org.apache.cassandra.stress.generate.Distribution;
+ import org.apache.cassandra.stress.generate.DistributionFactory;
+ import org.apache.cassandra.stress.generate.DistributionFixed;
+ import org.apache.cassandra.stress.generate.PartitionGenerator;
+ import org.apache.cassandra.stress.generate.Row;
+ import org.apache.cassandra.stress.settings.Command;
+ import org.apache.cassandra.stress.settings.CqlVersion;
+ import org.apache.cassandra.stress.settings.StressSettings;
+ import org.apache.cassandra.stress.util.Timer;
+ import org.apache.cassandra.thrift.ColumnParent;
+ import org.apache.cassandra.thrift.SlicePredicate;
+ import org.apache.cassandra.thrift.SliceRange;
+ import org.apache.cassandra.utils.ByteBufferUtil;
+ 
+ public abstract class PredefinedOperation extends Operation
+ {
+     public final Command type;
+     private final Distribution columnCount;
+     private Object cqlCache;
+ 
+     public PredefinedOperation(Command type, Timer timer, PartitionGenerator generator, StressSettings settings)
+     {
+         super(timer, generator, settings, new DistributionFixed(1));
+         this.type = type;
+         this.columnCount = settings.columns.countDistribution.get();
+     }
+ 
+     public boolean isCql3()
+     {
+         return settings.mode.cqlVersion == CqlVersion.CQL3;
+     }
 -    public boolean isCql2()
 -    {
 -        return settings.mode.cqlVersion == CqlVersion.CQL2;
 -    }
+     public Object getCqlCache()
+     {
+         return cqlCache;
+     }
+     public void storeCqlCache(Object val)
+     {
+         cqlCache = val;
+     }
+ 
+     protected ByteBuffer getKey()
+     {
+         return (ByteBuffer) partitions.get(0).getPartitionKey(0);
+     }
+ 
+     final class ColumnSelection
+     {
+         final int[] indices;
+         final int lb, ub;
+         private ColumnSelection(int[] indices, int lb, int ub)
+         {
+             this.indices = indices;
+             this.lb = lb;
+             this.ub = ub;
+         }
+ 
+         public <V> List<V> select(List<V> in)
+         {
+             List<V> out = new ArrayList<>();
+             if (indices != null)
+             {
+                 for (int i : indices)
+                     out.add(in.get(i));
+             }
+             else
+             {
+                 out.addAll(in.subList(lb, ub));
+             }
+             return out;
+         }
+ 
+         int count()
+         {
+             return indices != null ? indices.length : ub - lb;
+         }
+ 
+         SlicePredicate predicate()
+         {
+             final SlicePredicate predicate = new SlicePredicate();
+             if (indices == null)
+             {
+                 predicate.setSlice_range(new SliceRange()
+                                          .setStart(settings.columns.names.get(lb))
+                                          .setFinish(new byte[] {})
+                                          .setReversed(false)
+                                          .setCount(count())
+                 );
+             }
+             else
+                 predicate.setColumn_names(select(settings.columns.names));
+             return predicate;
+ 
+         }
+     }
+ 
+     public String toString()
+     {
+         return type.toString();
+     }
+ 
+     ColumnSelection select()
+     {
+         if (settings.columns.slice)
+         {
+             int count = (int) columnCount.next();
+             int start;
+             if (count == settings.columns.maxColumnsPerKey)
+                 start = 0;
+             else
+                 start = 1 + ThreadLocalRandom.current().nextInt(settings.columns.maxColumnsPerKey - count);
+             return new ColumnSelection(null, start, start + count);
+         }
+ 
+         int count = (int) columnCount.next();
+         int totalCount = settings.columns.names.size();
+         if (count == settings.columns.names.size())
+             return new ColumnSelection(null, 0, count);
+         ThreadLocalRandom rnd = ThreadLocalRandom.current();
+         int[] indices = new int[count];
+         int c = 0, o = 0;
+         while (c < count && count + o < totalCount)
+         {
+             int leeway = totalCount - (count + o);
+             int spreadover = count - c;
+             o += Math.round(rnd.nextDouble() * (leeway / (double) spreadover));
+             indices[c] = o + c;
+             c++;
+         }
+         while (c < count)
+         {
+             indices[c] = o + c;
+             c++;
+         }
+         return new ColumnSelection(indices, 0, 0);
+     }
+ 
+     protected List<ByteBuffer> getColumnValues()
+     {
+         return getColumnValues(new ColumnSelection(null, 0, settings.columns.names.size()));
+     }
+ 
+     protected List<ByteBuffer> getColumnValues(ColumnSelection columns)
+     {
+         Row row = partitions.get(0).iterator(1).batch(1f).iterator().next();
+         ByteBuffer[] r = new ByteBuffer[columns.count()];
+         int c = 0;
+         if (columns.indices != null)
+             for (int i : columns.indices)
+                 r[c++] = (ByteBuffer) row.get(i);
+         else
+             for (int i = columns.lb ; i < columns.ub ; i++)
+                 r[c++] = (ByteBuffer) row.get(i);
+         return Arrays.asList(r);
+     }
+ 
+     public static Operation operation(Command type, Timer timer, PartitionGenerator generator, StressSettings settings, DistributionFactory counteradd)
+     {
+         switch (type)
+         {
+             case READ:
+                 switch(settings.mode.style)
+                 {
+                     case THRIFT:
+                         return new ThriftReader(timer, generator, settings);
+                     case CQL:
+                     case CQL_PREPARED:
+                         return new CqlReader(timer, generator, settings);
+                     default:
+                         throw new UnsupportedOperationException();
+                 }
+ 
+ 
+             case COUNTER_READ:
+                 switch(settings.mode.style)
+                 {
+                     case THRIFT:
+                         return new ThriftCounterGetter(timer, generator, settings);
+                     case CQL:
+                     case CQL_PREPARED:
+                         return new CqlCounterGetter(timer, generator, settings);
+                     default:
+                         throw new UnsupportedOperationException();
+                 }
+ 
+             case WRITE:
+ 
+                 switch(settings.mode.style)
+                 {
+                     case THRIFT:
+                         return new ThriftInserter(timer, generator, settings);
+                     case CQL:
+                     case CQL_PREPARED:
+                         return new CqlInserter(timer, generator, settings);
+                     default:
+                         throw new UnsupportedOperationException();
+                 }
+ 
+             case COUNTER_WRITE:
+                 switch(settings.mode.style)
+                 {
+                     case THRIFT:
+                         return new ThriftCounterAdder(counteradd, timer, generator, settings);
+                     case CQL:
+                     case CQL_PREPARED:
+                         return new CqlCounterAdder(counteradd, timer, generator, settings);
+                     default:
+                         throw new UnsupportedOperationException();
+                 }
+ 
+         }
+ 
+         throw new UnsupportedOperationException();
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
index 0000000,5c2acfe..e71f3f5
mode 000000,100644..100644
--- a/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
+++ b/tools/stress/src/org/apache/cassandra/stress/operations/predefined/ThriftInserter.java
@@@ -1,0 -1,96 +1,98 @@@
+ /**
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ package org.apache.cassandra.stress.operations.predefined;
+ 
+ import java.io.IOException;
+ import java.nio.ByteBuffer;
+ import java.util.ArrayList;
+ import java.util.Collections;
+ import java.util.List;
+ import java.util.Map;
+ 
+ import org.apache.cassandra.db.marshal.TimeUUIDType;
+ import org.apache.cassandra.stress.generate.PartitionGenerator;
+ import org.apache.cassandra.stress.settings.Command;
+ import org.apache.cassandra.stress.settings.StressSettings;
+ import org.apache.cassandra.stress.util.ThriftClient;
+ import org.apache.cassandra.stress.util.Timer;
+ import org.apache.cassandra.thrift.*;
+ import org.apache.cassandra.utils.FBUtilities;
+ import org.apache.cassandra.utils.UUIDGen;
+ 
+ public final class ThriftInserter extends PredefinedOperation
+ {
+ 
+     public ThriftInserter(Timer timer, PartitionGenerator generator, StressSettings settings)
+     {
+         super(Command.WRITE, timer, generator, settings);
+     }
+ 
+     public void run(final ThriftClient client) throws IOException
+     {
+         final ByteBuffer key = getKey();
+         final List<Column> columns = getColumns();
+ 
+         List<Mutation> mutations = new ArrayList<>(columns.size());
+         for (Column c : columns)
+         {
+             ColumnOrSuperColumn column = new ColumnOrSuperColumn().setColumn(c);
+             mutations.add(new Mutation().setColumn_or_supercolumn(column));
+         }
+         Map<String, List<Mutation>> row = Collections.singletonMap(type.table, mutations);
+ 
+         final Map<ByteBuffer, Map<String, List<Mutation>>> record = Collections.singletonMap(key, row);
+ 
+         timeWithRetry(new RunOp()
+         {
+             @Override
+             public boolean run() throws Exception
+             {
+                 client.batch_mutate(record, settings.command.consistencyLevel);
+                 return true;
+             }
+ 
+             @Override
+             public int partitionCount()
+             {
+                 return 1;
+             }
+ 
+             @Override
+             public int rowCount()
+             {
+                 return 1;
+             }
+         });
+     }
+ 
+     protected List<Column> getColumns()
+     {
+         final ColumnSelection selection = select();
+         final List<ByteBuffer> values = getColumnValues(selection);
+         final List<Column> columns = new ArrayList<>(values.size());
+         final List<ByteBuffer> names = select().select(settings.columns.names);
+         for (int i = 0 ; i < values.size() ; i++)
+             columns.add(new Column(names.get(i))
+                         .setValue(values.get(i))
 -                        .setTimestamp(FBUtilities.timestampMicros()));
++                        .setTimestamp(settings.columns.timestamp != null
++                                      ? Long.parseLong(settings.columns.timestamp)
++                                      : FBUtilities.timestampMicros()));
+         return columns;
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
----------------------------------------------------------------------
diff --cc tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
index 4fac5d0,04c2a47..e48b49c
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java
@@@ -39,18 -41,13 +41,14 @@@ public class SettingsColumn implements 
  {
  
      public final int maxColumnsPerKey;
-     public final List<ByteBuffer> names;
+     public transient final List<ByteBuffer> names;
      public final List<String> namestrs;
      public final String comparator;
 +    public final String timestamp;
-     public final boolean useTimeUUIDComparator;
-     public final int superColumns;
-     public final boolean useSuperColumns;
      public final boolean variableColumnCount;
      public final boolean slice;
-     private final DistributionFactory sizeDistribution;
-     private final DistributionFactory countDistribution;
-     private final DataGenFactory dataGenFactory;
+     public final DistributionFactory sizeDistribution;
+     public final DistributionFactory countDistribution;
  
      public SettingsColumn(GroupedOptions options)
      {
@@@ -63,11 -60,7 +61,8 @@@
      public SettingsColumn(Options options, NameOptions name, CountOptions count)
      {
          sizeDistribution = options.size.get();
-         superColumns = Integer.parseInt(options.superColumns.value());
-         dataGenFactory = options.generator.get();
-         useSuperColumns = superColumns > 0;
          {
 +            timestamp = options.timestamp.value();
              comparator = options.comparator.value();
              AbstractType parsed = null;
  
@@@ -151,9 -146,7 +148,8 @@@
          final OptionSimple superColumns = new OptionSimple("super=", "[0-9]+", "0", "Number of super columns to use (no super columns used if not specified)", false);
          final OptionSimple comparator = new OptionSimple("comparator=", "TimeUUIDType|AsciiType|UTF8Type", "AsciiType", "Column Comparator to use", false);
          final OptionSimple slice = new OptionSimple("slice", "", null, "If set, range slices will be used for reads, otherwise a names query will be", false);
 +        final OptionSimple timestamp = new OptionSimple("timestamp=", "[0-9]+", null, "If set, all columns will be written with the given timestamp", false);
          final OptionDistribution size = new OptionDistribution("size=", "FIXED(34)", "Cell size distribution");
-         final OptionDataGen generator = new OptionDataGen("data=", "REPEAT(50)");
      }
  
      private static final class NameOptions extends Options
@@@ -163,7 -156,7 +159,7 @@@
          @Override
          public List<? extends Option> options()
          {
-             return Arrays.asList(name, slice, superColumns, comparator, timestamp, size, generator);
 -            return Arrays.asList(name, slice, superColumns, comparator, size);
++            return Arrays.asList(name, slice, superColumns, comparator, timestamp, size);
          }
      }
  
@@@ -174,7 -167,7 +170,7 @@@
          @Override
          public List<? extends Option> options()
          {
-             return Arrays.asList(count, slice, superColumns, comparator, timestamp, size, generator);
 -            return Arrays.asList(count, slice, superColumns, comparator, size);
++            return Arrays.asList(count, slice, superColumns, comparator, timestamp, size);
          }
      }
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/047c0461/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java
----------------------------------------------------------------------


Mime
View raw message