cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject [2/6] cassandra git commit: Add consistency level to tracing ouput
Date Mon, 27 Jul 2015 20:40:13 GMT
Add consistency level to tracing ouput

patch by Alec Grieser; reviewed by Richard Low for CASSANDRA-9827


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

Branch: refs/heads/cassandra-2.2
Commit: 9dbf32cd824002b678b03afde8c441a85418a943
Parents: 9ed0f30
Author: Alec Grieser <ahgrieser@gmail.com>
Authored: Mon Jul 27 22:36:41 2015 +0200
Committer: Robert Stupp <snazy@snazy.de>
Committed: Mon Jul 27 22:36:41 2015 +0200

----------------------------------------------------------------------
 CHANGES.txt                                       |  1 +
 .../apache/cassandra/thrift/CassandraServer.java  | 18 ++++++++++++------
 .../transport/messages/BatchMessage.java          | 11 +++++++++--
 .../transport/messages/ExecuteMessage.java        |  4 ++++
 .../transport/messages/QueryMessage.java          |  5 ++++-
 5 files changed, 30 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dbf32cd/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9cb7b83..5aee7ba 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.9
+ * Add consistency level to tracing ouput (CASSANDRA-9827)
  * Fix MarshalException when upgrading superColumn family (CASSANDRA-9582)
  * Fix broken logging for "empty" flushes in Memtable (CASSANDRA-9837)
  * Handle corrupt files on startup (CASSANDRA-9686)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dbf32cd/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index e8d08b5..fd87b57 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -733,10 +733,15 @@ public class CassandraServer implements Cassandra.Iface
     {
         if (startSessionIfRequested())
         {
-            Map<String, String> traceParameters = ImmutableMap.of("key", ByteBufferUtil.bytesToHex(key),
-                                                                  "column_family", column_family,
-                                                                  "old", expected.toString(),
-                                                                  "updates", updates.toString());
+            ImmutableMap.Builder<String,String> builder = ImmutableMap.builder();
+            builder.put("key", ByteBufferUtil.bytesToHex(key));
+            builder.put("column_family", column_family);
+            builder.put("old", expected.toString());
+            builder.put("updates", updates.toString());
+            builder.put("consistency_level", commit_consistency_level.name());
+            builder.put("serial_consistency_level", serial_consistency_level.name());
+            Map<String,String> traceParameters = builder.build();
+
             Tracing.instance.begin("cas", traceParameters);
         }
         else
@@ -1969,7 +1974,8 @@ public class CassandraServer implements Cassandra.Iface
             if (startSessionIfRequested())
             {
                 Tracing.instance.begin("execute_cql3_query",
-                                       ImmutableMap.of("query", queryString));
+                                       ImmutableMap.of("query", queryString,
+                                                       "consistency_level", cLevel.name()));
             }
             else
             {
@@ -2160,7 +2166,7 @@ public class CassandraServer implements Cassandra.Iface
         if (startSessionIfRequested())
         {
             // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560
is open to add support.
-            Tracing.instance.begin("execute_prepared_cql3_query", Collections.<String,
String>emptyMap());
+            Tracing.instance.begin("execute_prepared_cql3_query", ImmutableMap.of("consistency_level",
cLevel.name()));
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dbf32cd/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/BatchMessage.java b/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
index ff791ef..b34b156 100644
--- a/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
@@ -19,10 +19,10 @@ package org.apache.cassandra.transport.messages;
 
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.UUID;
 
+import com.google.common.collect.ImmutableMap;
 import io.netty.buffer.ByteBuf;
 
 import org.apache.cassandra.cql3.*;
@@ -166,8 +166,15 @@ public class BatchMessage extends Message.Request
             if (state.traceNextQuery())
             {
                 state.createTracingSession();
+
+                ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
+                if(options.getConsistency() != null)
+                    builder.put("consistency_level", options.getConsistency().name());
+                if(options.getSerialConsistency() != null)
+                    builder.put("serial_consistency_level", options.getSerialConsistency().name());
+
                 // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560
is open to add support.
-                Tracing.instance.begin("Execute batch of CQL3 queries", Collections.<String,
String>emptyMap());
+                Tracing.instance.begin("Execute batch of CQL3 queries", builder.build());
             }
 
             QueryHandler handler = ClientState.getCQLQueryHandler();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dbf32cd/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java b/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java
index 324ae00..7dd5f83 100644
--- a/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java
@@ -126,6 +126,10 @@ public class ExecuteMessage extends Message.Request
                 ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
                 if (options.getPageSize() > 0)
                     builder.put("page_size", Integer.toString(options.getPageSize()));
+                if(options.getConsistency() != null)
+                    builder.put("consistency_level", options.getConsistency().name());
+                if(options.getSerialConsistency() != null)
+                    builder.put("serial_consistency_level", options.getSerialConsistency().name());
 
                 // TODO we don't have [typed] access to CQL bind variables here.  CASSANDRA-4560
is open to add support.
                 Tracing.instance.begin("Execute CQL3 prepared query", builder.build());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9dbf32cd/src/java/org/apache/cassandra/transport/messages/QueryMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/QueryMessage.java b/src/java/org/apache/cassandra/transport/messages/QueryMessage.java
index ff50422..2dd98cc 100644
--- a/src/java/org/apache/cassandra/transport/messages/QueryMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/QueryMessage.java
@@ -24,7 +24,6 @@ import java.util.UUID;
 import com.google.common.collect.ImmutableMap;
 import io.netty.buffer.ByteBuf;
 
-import org.apache.cassandra.cql3.QueryHandler;
 import org.apache.cassandra.cql3.QueryOptions;
 import org.apache.cassandra.db.ConsistencyLevel;
 import org.apache.cassandra.exceptions.*;
@@ -112,6 +111,10 @@ public class QueryMessage extends Message.Request
                 builder.put("query", query);
                 if (options.getPageSize() > 0)
                     builder.put("page_size", Integer.toString(options.getPageSize()));
+                if(options.getConsistency() != null)
+                    builder.put("consistency_level", options.getConsistency().name());
+                if(options.getSerialConsistency() != null)
+                    builder.put("serial_consistency_level", options.getSerialConsistency().name());
 
                 Tracing.instance.begin("Execute CQL3 query", builder.build());
             }


Mime
View raw message