mirror of https://github.com/apache/cassandra
cqlsh: add SHOW SESSION <tracing-session> command
patch by Mikhail Stepura; reviewed by Aleksey Yeschenko for CASSANDRA-6228
This commit is contained in:
parent
322f9a9831
commit
941cd456ae
|
|
@ -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)
|
||||
|
|
|
|||
14
bin/cqlsh
14
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,))
|
||||
|
||||
|
|
|
|||
|
|
@ -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> ::= "*" ;
|
||||
|
|
|
|||
|
|
@ -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 "
|
||||
|
|
|
|||
Loading…
Reference in New Issue