cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Revert "Revert "Update cqlsh driver for new driver execution API""
Date Wed, 04 Nov 2015 14:22:16 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 5a2d52984 -> 9404fed01


Revert "Revert "Update cqlsh driver for new driver execution API""

This reverts commit 0fbf715916b48a8e8abad5911e2697791b49f824.


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

Branch: refs/heads/cassandra-2.2
Commit: 9404fed01ae2f354f90e68d52c7d0b92196cc62a
Parents: 5a2d529
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Wed Nov 4 14:21:18 2015 +0000
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Wed Nov 4 14:21:18 2015 +0000

----------------------------------------------------------------------
 bin/cqlsh.py                                    |  69 +++++++++----------
 lib/cassandra-driver-internal-only-2.7.2.zip    | Bin 229600 -> 0 bytes
 ...iver-internal-only-3.0.0a2.post0-95c6008.zip | Bin 0 -> 233564 bytes
 3 files changed, 31 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9404fed0/bin/cqlsh.py
----------------------------------------------------------------------
diff --git a/bin/cqlsh.py b/bin/cqlsh.py
index 09da020..17bddd3 100644
--- a/bin/cqlsh.py
+++ b/bin/cqlsh.py
@@ -111,13 +111,13 @@ except ImportError, e:
              'Error: %s\n' % (sys.executable, sys.path, e))
 
 from cassandra.auth import PlainTextAuthProvider
-from cassandra.cluster import Cluster, PagedResult
+from cassandra.cluster import Cluster
 from cassandra.metadata import (ColumnMetadata, KeyspaceMetadata,
                                 TableMetadata, protect_name, protect_names,
                                 protect_value)
 from cassandra.policies import WhiteListRoundRobinPolicy
 from cassandra.protocol import QueryMessage, ResultMessage
-from cassandra.query import SimpleStatement, ordered_dict_factory
+from cassandra.query import SimpleStatement, ordered_dict_factory, TraceUnavailable
 
 # cqlsh should run correctly when run out of a Cassandra source tree,
 # out of an unpacked Cassandra tarball, and after a proper package install.
@@ -675,6 +675,7 @@ class Shell(cmd.Cmd):
 
         self.session.default_timeout = client_timeout
         self.session.row_factory = ordered_dict_factory
+        self.session.default_consistency_level = cassandra.ConsistencyLevel.ONE
         self.get_connection_versions()
 
         self.current_keyspace = keyspace
@@ -1121,8 +1122,8 @@ class Shell(cmd.Cmd):
 
     def do_use(self, parsed):
         ksname = parsed.get_binding('ksname')
-        result, future = self.perform_simple_statement(SimpleStatement(parsed.extract_orig()))
-        if result:
+        success, _ = self.perform_simple_statement(SimpleStatement(parsed.extract_orig()))
+        if success:
             if ksname[0] == '"' and ksname[-1] == '"':
                 self.current_keyspace = self.cql_unprotect_name(ksname)
             else:
@@ -1139,7 +1140,7 @@ class Shell(cmd.Cmd):
 
     def perform_statement(self, statement):
         stmt = SimpleStatement(statement, consistency_level=self.consistency_level, serial_consistency_level=self.serial_consistency_level,
fetch_size=self.page_size if self.use_paging else None)
-        result, future = self.perform_simple_statement(stmt)
+        success, future = self.perform_simple_statement(stmt)
 
         if future:
             if future.warnings:
@@ -1147,19 +1148,17 @@ class Shell(cmd.Cmd):
 
             if self.tracing_enabled:
                 try:
-                    trace = future.get_query_trace(self.max_trace_wait)
-                    if trace:
+                    for trace in future.get_all_query_traces(self.max_trace_wait):
                         print_trace(self, trace)
-                    elif stmt.trace_id:
-                        self.writeresult("This statement trace may be incomplete", color=RED)
-                        self.show_session(stmt.trace_id)
-                    else:
-                        msg = "Statement trace did not complete within %d seconds" % (self.session.max_trace_wait)
-                        self.writeresult(msg, color=RED)
+                except TraceUnavailable:
+                    msg = "Statement trace did not complete within %d seconds; trace data
may be incomplete." % (self.session.max_trace_wait,)
+                    self.writeresult(msg, color=RED)
+                    for trace_id in future.get_query_trace_ids():
+                        self.show_session(trace_id)
                 except Exception, err:
                     self.printerr("Unable to fetch query trace: %s" % (str(err),))
 
-        return result
+        return success
 
     def parse_for_table_meta(self, query_string):
         try:
@@ -1177,7 +1176,7 @@ class Shell(cmd.Cmd):
         while True:
             try:
                 future = self.session.execute_async(statement, trace=self.tracing_enabled)
-                rows = future.result(self.session.default_timeout)
+                result = future.result()
                 break
             except cassandra.OperationTimedOut, err:
                 self.refresh_schema_metadata_best_effort()
@@ -1192,42 +1191,36 @@ class Shell(cmd.Cmd):
                 return False, None
 
         if statement.query_string[:6].lower() == 'select':
-            self.print_result(rows, self.parse_for_table_meta(statement.query_string))
+            self.print_result(result, self.parse_for_table_meta(statement.query_string))
         elif statement.query_string.lower().startswith("list users") or statement.query_string.lower().startswith("list
roles"):
-            self.print_result(rows, self.get_table_meta('system_auth', 'roles'))
+            self.print_result(result, self.get_table_meta('system_auth', 'roles'))
         elif statement.query_string.lower().startswith("list"):
-            self.print_result(rows, self.get_table_meta('system_auth', 'role_permissions'))
-        elif rows:
+            self.print_result(result, self.get_table_meta('system_auth', 'role_permissions'))
+        elif result:
             # CAS INSERT/UPDATE
             self.writeresult("")
-            self.print_static_result(rows, self.parse_for_table_meta(statement.query_string))
+            self.print_static_result(list(result), self.parse_for_table_meta(statement.query_string))
         self.flush_output()
         return True, future
 
-    def print_result(self, rows, table_meta):
+    def print_result(self, result, table_meta):
         self.decoding_errors = []
 
         self.writeresult("")
-        if isinstance(rows, PagedResult) and self.tty:
+        if result.has_more_pages and self.tty:
             num_rows = 0
             while True:
-                page = list(rows.current_response)
-                if not page:
-                    break
-                num_rows += len(page)
-                self.print_static_result(page, table_meta)
-                if not rows.response_future.has_more_pages:
-                    break
-                raw_input("---MORE---")
-
-                rows.response_future.start_fetching_next_page()
-                result = rows.response_future.result()
-                if rows.response_future.has_more_pages:
-                    rows.current_response = result.current_response
+                page = result.current_rows
+                if page:
+                    num_rows += len(page)
+                    self.print_static_result(page, table_meta)
+                if result.has_more_pages:
+                    raw_input("---MORE---")
+                    result.fetch_next_page()
                 else:
-                    rows.current_response = iter(result)
+                    break
         else:
-            rows = list(rows or [])
+            rows = list(result)
             num_rows = len(rows)
             self.print_static_result(rows, table_meta)
         self.writeresult("(%d rows)" % num_rows)
@@ -2335,7 +2328,7 @@ class ImportProcess(multiprocessing.Process):
         cqltypes = [table_meta.columns[name].typestring for name in self.columns]
         pk_indexes = [self.columns.index(col.name) for col in table_meta.primary_key]
         query = 'INSERT INTO %s.%s (%s) VALUES (%%s)' % (
-            protect_name(table_meta.keyspace.name),
+            protect_name(table_meta.keyspace_name),
             protect_name(table_meta.name),
             ', '.join(protect_names(self.columns)))
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9404fed0/lib/cassandra-driver-internal-only-2.7.2.zip
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-internal-only-2.7.2.zip b/lib/cassandra-driver-internal-only-2.7.2.zip
deleted file mode 100644
index f2e75f1..0000000
Binary files a/lib/cassandra-driver-internal-only-2.7.2.zip and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9404fed0/lib/cassandra-driver-internal-only-3.0.0a2.post0-95c6008.zip
----------------------------------------------------------------------
diff --git a/lib/cassandra-driver-internal-only-3.0.0a2.post0-95c6008.zip b/lib/cassandra-driver-internal-only-3.0.0a2.post0-95c6008.zip
new file mode 100644
index 0000000..da7fa0d
Binary files /dev/null and b/lib/cassandra-driver-internal-only-3.0.0a2.post0-95c6008.zip
differ


Mime
View raw message