You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2013/10/23 16:36:13 UTC
git commit: cqlsh: add SHOW SESSION command
Updated Branches:
refs/heads/cassandra-2.0 322f9a983 -> 941cd456a
cqlsh: add SHOW SESSION <tracing-session> command
patch by Mikhail Stepura; reviewed by Aleksey Yeschenko for
CASSANDRA-6228
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/941cd456
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/941cd456
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/941cd456
Branch: refs/heads/cassandra-2.0
Commit: 941cd456ae1d0fd933a540468d2f9f13764d6de3
Parents: 322f9a9
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Wed Oct 23 22:35:14 2013 +0800
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Wed Oct 23 22:35:14 2013 +0800
----------------------------------------------------------------------
CHANGES.txt | 1 +
bin/cqlsh | 14 ++++++++++++--
pylib/cqlshlib/cql3handling.py | 2 +-
pylib/cqlshlib/tracing.py | 8 +++++++-
4 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/941cd456/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 47e52f1..9f7f3f0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,7 @@
2.0.3
* Reject bootstrapping if the node already exists in gossip (CASSANDRA-5571)
* Fix NPE while loading paxos state (CASSANDRA-6211)
+ * cqlsh: add SHOW SESSION <tracing-session> command (CASSANDRA-6228)
Merged from 1.2:
* Fix altering column types (CASSANDRA-6185)
* cqlsh: fix CREATE/ALTER WITH completion (CASSANDRA-6196)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/941cd456/bin/cqlsh
----------------------------------------------------------------------
diff --git a/bin/cqlsh b/bin/cqlsh
index 82c9906..3382111 100755
--- a/bin/cqlsh
+++ b/bin/cqlsh
@@ -32,7 +32,7 @@ exit 1
from __future__ import with_statement
description = "CQL Shell for Apache Cassandra"
-version = "4.0.2"
+version = "4.1.0"
from StringIO import StringIO
from itertools import groupby
@@ -245,7 +245,7 @@ cqlsh_extra_syntax_rules = r'''
| "EACH_QUORUM"
;
-<showCommand> ::= "SHOW" what=( "VERSION" | "HOST" )
+<showCommand> ::= "SHOW" what=( "VERSION" | "HOST" | "SESSION" sessionid=<uuid> )
;
<sourceCommand> ::= "SOURCE" fname=<stringLiteral>
@@ -569,6 +569,9 @@ class Shell(cmd.Cmd):
vers['cql'] = self.cql_version
print "[cqlsh %(shver)s | Cassandra %(build)s | CQL spec %(cql)s | Thrift protocol %(thrift)s]" % vers
+ def show_session(self, sessionid):
+ print_trace_session(self, self.cursor, sessionid)
+
def get_connection_versions(self):
self.cursor.execute("select * from system.local where key = 'local'")
result = self.fetchdict()
@@ -1554,6 +1557,10 @@ class Shell(cmd.Cmd):
SHOW HOST
Shows where cqlsh is currently connected.
+
+ SHOW SESSION <sessionid>
+
+ Pretty-prints the requested tracing session.
"""
showwhat = parsed.get_binding('what').lower()
if showwhat == 'version':
@@ -1561,6 +1568,9 @@ class Shell(cmd.Cmd):
self.show_version()
elif showwhat == 'host':
self.show_host()
+ elif showwhat.startswith('session'):
+ session_id = parsed.get_binding('sessionid').lower()
+ self.show_session(session_id)
else:
self.printerr('Wait, how do I show %r?' % (showwhat,))
http://git-wip-us.apache.org/repos/asf/cassandra/blob/941cd456/pylib/cqlshlib/cql3handling.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/cql3handling.py b/pylib/cqlshlib/cql3handling.py
index bc349a7..e7aa9e1 100644
--- a/pylib/cqlshlib/cql3handling.py
+++ b/pylib/cqlshlib/cql3handling.py
@@ -177,8 +177,8 @@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
<stringLiteral> ::= /'([^']|'')*'/ ;
<quotedName> ::= /"([^"]|"")*"/ ;
<float> ::= /-?[0-9]+\.[0-9]+/ ;
-<wholenumber> ::= /[0-9]+/ ;
<uuid> ::= /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ ;
+<wholenumber> ::= /[0-9]+/ ;
<identifier> ::= /[a-z][a-z0-9_]*/ ;
<colon> ::= ":" ;
<star> ::= "*" ;
http://git-wip-us.apache.org/repos/asf/cassandra/blob/941cd456/pylib/cqlshlib/tracing.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/tracing.py b/pylib/cqlshlib/tracing.py
index fb8525d..02d3296 100644
--- a/pylib/cqlshlib/tracing.py
+++ b/pylib/cqlshlib/tracing.py
@@ -24,6 +24,9 @@ EVENTS_CF = 'events'
def print_trace_session(shell, cursor, session_id):
rows = fetch_trace_session(cursor, session_id)
+ if not rows:
+ shell.printerr("Session %s wasn't found." % session_id)
+ return
names = ['activity', 'timestamp', 'source', 'source_elapsed']
types = [UTF8Type, UTF8Type, InetAddressType, Int32Type]
@@ -42,7 +45,10 @@ def fetch_trace_session(cursor, session_id):
"FROM %s.%s "
"WHERE session_id = %s" % (TRACING_KS, SESSIONS_CF, session_id),
consistency_level='ONE')
- (request, coordinator, started_at, duration) = cursor.fetchone()
+ session = cursor.fetchone()
+ if not session:
+ return []
+ (request, coordinator, started_at, duration) = session
cursor.execute("SELECT activity, event_id, source, source_elapsed "
"FROM %s.%s "