From 37abae6c32b0e81ce4889b1c8714e9c479b52e85 Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Sat, 12 Jul 2014 14:17:48 +1100 Subject: [PATCH] Configurable client timeout for cqlsh. patch by Ryan McGuire; reviewed by Mikhail Stepura for CASSANDRA-7516 --- CHANGES.txt | 1 + bin/cqlsh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ce885eb461..27c28ae68e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,7 @@ * Fix NPE when unknown prepared statement ID is used (CASSANDRA-7454) * Adjust MT depth based on # of partition validating (CASSANDRA-5263) * Optimise NativeCell comparisons (CASSANDRA-6755) + * Configurable client timeout for cqlsh (CASSANDRA-7516) 2.1.0-final diff --git a/bin/cqlsh b/bin/cqlsh index c3a4ea6e35..9a6d5361ff 100755 --- a/bin/cqlsh +++ b/bin/cqlsh @@ -467,7 +467,8 @@ class Shell(cmd.Cmd): display_time_format=DEFAULT_TIME_FORMAT, display_float_precision=DEFAULT_FLOAT_PRECISION, ssl=False, - single_statement=None): + single_statement=None, + client_timeout=10): cmd.Cmd.__init__(self, completekey=completekey) self.hostname = hostname self.port = port @@ -493,6 +494,7 @@ class Shell(cmd.Cmd): self.session = self.conn.connect(keyspace) else: self.session = self.conn.connect() + self.session.default_timeout = client_timeout self.get_connection_versions() self.current_keyspace = keyspace @@ -1778,6 +1780,11 @@ def read_options(cmdlineargs, environment): hostname = option_with_default(configs.get, 'connection', 'hostname', DEFAULT_HOST) port = option_with_default(configs.get, 'connection', 'port', DEFAULT_PORT) + options.client_timeout = option_with_default(configs.get, 'connection', 'client_timeout', '10') + if options.client_timeout.lower() == 'none': + options.client_timeout = None + else: + options.client_timeout = int(options.client_timeout) hostname = environment.get('CQLSH_HOST', hostname) port = environment.get('CQLSH_PORT', port) @@ -1874,7 +1881,8 @@ def main(options, hostname, port): display_time_format=options.time_format, display_float_precision=options.float_precision, ssl=options.ssl, - single_statement=options.execute) + single_statement=options.execute, + client_timeout=options.client_timeout) except KeyboardInterrupt: sys.exit('Connection aborted.') except CQL_ERRORS, e: