cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [2/3] cassandra git commit: CASSANDRA-11410 – Option to specify ProtocolVersion in cassandra-stress
Date Mon, 18 Apr 2016 14:01:55 GMT
CASSANDRA-11410 – Option to specify ProtocolVersion in cassandra-stress

Patch by mck; reviewed by tjake for CASSANDRA-11410


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

Branch: refs/heads/trunk
Commit: 99ea2ee716d54ac2045b3882c6dc1fe6dca0d65f
Parents: ce44599
Author: mck <mck@apache.org>
Authored: Wed Mar 23 18:34:10 2016 +1100
Committer: T Jake Luciani <jake@apache.org>
Committed: Mon Apr 18 09:58:31 2016 -0400

----------------------------------------------------------------------
 CHANGES.txt                                               |  1 +
 .../apache/cassandra/stress/settings/SettingsMode.java    | 10 +++++++++-
 .../apache/cassandra/stress/util/JavaDriverClient.java    |  4 +++-
 3 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/99ea2ee7/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 85660d9..c9538a8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.6
+ * Option to specify ProtocolVersion in cassandra-stress (CASSANDRA-11410)
  * ArithmeticException in avgFunctionForDecimal (CASSANDRA-11485)
  * Allow only DISTINCT queries with partition keys or static columns restrictions (CASSANDRA-11339)
  * LogAwareFileLister should only use OLD sstable files in current folder to determine disk
consistency (CASSANDRA-11470)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/99ea2ee7/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java
index 699f10e..8f0ab25 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import com.datastax.driver.core.AuthProvider;
 import com.datastax.driver.core.PlainTextAuthProvider;
 import com.datastax.driver.core.ProtocolOptions;
+import com.datastax.driver.core.ProtocolVersion;
 
 public class SettingsMode implements Serializable
 {
@@ -36,6 +37,7 @@ public class SettingsMode implements Serializable
     public final ConnectionAPI api;
     public final ConnectionStyle style;
     public final CqlVersion cqlVersion;
+    public final ProtocolVersion protocolVersion;
 
     public final String username;
     public final String password;
@@ -53,6 +55,9 @@ public class SettingsMode implements Serializable
         {
             cqlVersion = CqlVersion.CQL3;
             Cql3Options opts = (Cql3Options) options;
+            protocolVersion = "NEWEST_SUPPORTED".equals(opts.protocolVersion.value())
+                    ? ProtocolVersion.NEWEST_SUPPORTED
+                    : ProtocolVersion.fromInt(Integer.parseInt(opts.protocolVersion.value()));
             api = opts.mode().displayPrefix.equals("native") ? ConnectionAPI.JAVA_DRIVER_NATIVE
: ConnectionAPI.THRIFT;
             style = opts.useUnPrepared.setByUser() ? ConnectionStyle.CQL :  ConnectionStyle.CQL_PREPARED;
             compression = ProtocolOptions.Compression.valueOf(opts.useCompression.value().toUpperCase()).name();
@@ -92,6 +97,7 @@ public class SettingsMode implements Serializable
         {
             cqlVersion = CqlVersion.CQL3;
             Cql3SimpleNativeOptions opts = (Cql3SimpleNativeOptions) options;
+            protocolVersion = ProtocolVersion.NEWEST_SUPPORTED;
             api = ConnectionAPI.SIMPLE_NATIVE;
             style = opts.usePrepared.setByUser() ? ConnectionStyle.CQL_PREPARED : ConnectionStyle.CQL;
             compression = ProtocolOptions.Compression.NONE.name();
@@ -105,6 +111,7 @@ public class SettingsMode implements Serializable
         else if (options instanceof ThriftOptions)
         {
             ThriftOptions opts = (ThriftOptions) options;
+            protocolVersion = ProtocolVersion.NEWEST_SUPPORTED;
             cqlVersion = CqlVersion.NOCQL;
             api = opts.smart.setByUser() ? ConnectionAPI.THRIFT_SMART : ConnectionAPI.THRIFT;
             style = ConnectionStyle.THRIFT;
@@ -148,6 +155,7 @@ public class SettingsMode implements Serializable
     private static abstract class Cql3Options extends GroupedOptions
     {
         final OptionSimple api = new OptionSimple("cql3", "", null, "", true);
+        final OptionSimple protocolVersion = new OptionSimple("protocolVersion=", "[2-4]+",
"NEWEST_SUPPORTED", "CQL Protocol Version", false);
         final OptionSimple useUnPrepared = new OptionSimple("unprepared", "", null, "force
use of unprepared statements", false);
         final OptionSimple useCompression = new OptionSimple("compression=", "none|lz4|snappy",
"none", "", false);
         final OptionSimple port = new OptionSimple("port=", "[0-9]+", "9046", "", false);
@@ -162,7 +170,7 @@ public class SettingsMode implements Serializable
         public List<? extends Option> options()
         {
             return Arrays.asList(mode(), useUnPrepared, api, useCompression, port, user,
password, authProvider,
-                                 maxPendingPerConnection, connectionsPerHost);
+                                 maxPendingPerConnection, connectionsPerHost, protocolVersion);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/99ea2ee7/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
index bbf1008..4f173b4 100644
--- a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
+++ b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java
@@ -47,6 +47,7 @@ public class JavaDriverClient
     public final int maxPendingPerConnection;
     public final int connectionsPerHost;
 
+    private final ProtocolVersion protocolVersion;
     private final EncryptionOptions.ClientEncryptionOptions encryptionOptions;
     private Cluster cluster;
     private Session session;
@@ -61,6 +62,7 @@ public class JavaDriverClient
 
     public JavaDriverClient(StressSettings settings, String host, int port, EncryptionOptions.ClientEncryptionOptions
encryptionOptions)
     {
+        this.protocolVersion = settings.mode.protocolVersion;
         this.host = host;
         this.port = port;
         this.username = settings.mode.username;
@@ -115,7 +117,7 @@ public class JavaDriverClient
                                                 .withPort(port)
                                                 .withPoolingOptions(poolingOpts)
                                                 .withoutJMXReporting()
-                                                .withProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED)
+                                                .withProtocolVersion(protocolVersion)
                                                 .withoutMetrics(); // The driver uses metrics
3 with conflict with our version
         if (whitelist != null)
             clusterBuilder.withLoadBalancingPolicy(whitelist);


Mime
View raw message