From de946ae45ad8af3718d4159e885e6700230d4818 Mon Sep 17 00:00:00 2001 From: Julien Blondeau Date: Tue, 12 Jan 2016 11:51:20 -0600 Subject: [PATCH] cqlsh: Apply --connect-timeout to control conn Patch by Julien Blondeau; reviewed by Tyler Hobbs for CASSANDRA-10959 --- CHANGES.txt | 2 ++ bin/cqlsh.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 477a104ae0..f895139e0b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 2.2.5 + * (cqlsh) Also apply --connect-timeout to control connection + timeout (CASSANDRA-10959) * Histogram buckets exposed in jmx are sorted incorrectly (CASSANDRA-10975) * Enable GC logging by default (CASSANDRA-10140) * Optimize pending range computation (CASSANDRA-9258) diff --git a/bin/cqlsh.py b/bin/cqlsh.py index c38bc2e7d2..be2ad46ae7 100644 --- a/bin/cqlsh.py +++ b/bin/cqlsh.py @@ -141,7 +141,6 @@ from cassandra.cluster import Cluster from cassandra.metadata import (ColumnMetadata, KeyspaceMetadata, TableMetadata, protect_name, protect_names) from cassandra.policies import WhiteListRoundRobinPolicy -from cassandra.protocol import ResultMessage from cassandra.query import SimpleStatement, ordered_dict_factory, TraceUnavailable # cqlsh should run correctly when run out of a Cassandra source tree, @@ -683,6 +682,7 @@ class Shell(cmd.Cmd): auth_provider=self.auth_provider, ssl_options=sslhandling.ssl_settings(hostname, CONFIG_FILE) if ssl else None, load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname]), + control_connection_timeout=connect_timeout, connect_timeout=connect_timeout) self.owns_connection = not use_conn self.set_expanded_cql_version(cqlver) @@ -1201,7 +1201,7 @@ class Shell(cmd.Cmd): def perform_simple_statement(self, statement): if not statement: return False, None - rows = None + while True: try: future = self.session.execute_async(statement, trace=self.tracing_enabled) @@ -2047,6 +2047,7 @@ class Shell(cmd.Cmd): auth_provider=auth_provider, ssl_options=self.conn.ssl_options, load_balancing_policy=WhiteListRoundRobinPolicy([self.hostname]), + control_connection_timeout=self.conn.connect_timeout, connect_timeout=self.conn.connect_timeout) if self.current_keyspace: