cassandra-driver 1.0.0.rc.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +45 -10
- data/lib/cassandra.rb +82 -82
- data/lib/cassandra/cluster.rb +3 -0
- data/lib/cassandra/cluster/client.rb +17 -5
- data/lib/cassandra/{client/connection_manager.rb → cluster/connection_pool.rb} +3 -3
- data/lib/cassandra/cluster/connector.rb +101 -30
- data/lib/cassandra/cluster/control_connection.rb +6 -7
- data/lib/cassandra/{client/null_logger.rb → cluster/failed_connection.rb} +12 -14
- data/lib/cassandra/cluster/options.rb +8 -0
- data/lib/cassandra/column.rb +5 -0
- data/lib/cassandra/driver.rb +3 -3
- data/lib/cassandra/errors.rb +5 -5
- data/lib/cassandra/execution/options.rb +13 -6
- data/lib/cassandra/execution/trace.rb +4 -4
- data/lib/cassandra/future.rb +4 -0
- data/lib/cassandra/keyspace.rb +5 -0
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +7 -2
- data/lib/cassandra/load_balancing/policies/token_aware.rb +1 -3
- data/lib/cassandra/load_balancing/policies/white_list.rb +3 -6
- data/lib/cassandra/null_logger.rb +35 -0
- data/lib/cassandra/protocol/cql_protocol_handler.rb +4 -0
- data/lib/cassandra/protocol/requests/query_request.rb +1 -11
- data/lib/cassandra/result.rb +4 -6
- data/lib/cassandra/session.rb +3 -0
- data/lib/cassandra/statements/prepared.rb +5 -1
- data/lib/cassandra/table.rb +5 -0
- data/lib/cassandra/util.rb +130 -0
- data/lib/cassandra/version.rb +1 -1
- metadata +9 -20
- data/lib/cassandra/client.rb +0 -144
- data/lib/cassandra/client/batch.rb +0 -212
- data/lib/cassandra/client/client.rb +0 -591
- data/lib/cassandra/client/column_metadata.rb +0 -54
- data/lib/cassandra/client/connector.rb +0 -273
- data/lib/cassandra/client/execute_options_decoder.rb +0 -59
- data/lib/cassandra/client/peer_discovery.rb +0 -50
- data/lib/cassandra/client/prepared_statement.rb +0 -314
- data/lib/cassandra/client/query_result.rb +0 -230
- data/lib/cassandra/client/request_runner.rb +0 -70
- data/lib/cassandra/client/result_metadata.rb +0 -48
- data/lib/cassandra/client/void_result.rb +0 -78
data/lib/cassandra/cluster.rb
CHANGED
@@ -191,6 +191,7 @@ module Cassandra
|
|
191
191
|
|
192
192
|
@control_connection.close_async.on_complete do |f|
|
193
193
|
if f.resolved?
|
194
|
+
@load_balancing_policy.teardown(self) rescue nil
|
194
195
|
promise.fulfill(self)
|
195
196
|
else
|
196
197
|
f.on_failure {|e| promise.break(e)}
|
@@ -217,8 +218,10 @@ module Cassandra
|
|
217
218
|
end
|
218
219
|
|
219
220
|
require 'cassandra/cluster/client'
|
221
|
+
require 'cassandra/cluster/connection_pool'
|
220
222
|
require 'cassandra/cluster/connector'
|
221
223
|
require 'cassandra/cluster/control_connection'
|
224
|
+
require 'cassandra/cluster/failed_connection'
|
222
225
|
require 'cassandra/cluster/metadata'
|
223
226
|
require 'cassandra/cluster/options'
|
224
227
|
require 'cassandra/cluster/registry'
|
@@ -63,11 +63,12 @@ module Cassandra
|
|
63
63
|
@connected_future = begin
|
64
64
|
@logger.info('Creating session')
|
65
65
|
@registry.add_listener(self)
|
66
|
+
@schema.add_listener(self)
|
66
67
|
|
67
68
|
futures = @connecting_hosts.map do |(host, distance)|
|
68
69
|
f = connect_to_host(host, distance)
|
69
70
|
f.recover do |error|
|
70
|
-
|
71
|
+
FailedConnection.new(error, host)
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -100,6 +101,7 @@ module Cassandra
|
|
100
101
|
|
101
102
|
@closed_future = begin
|
102
103
|
@registry.remove_listener(self)
|
104
|
+
@schema.remove_listener(self)
|
103
105
|
|
104
106
|
if state == :connecting
|
105
107
|
f = @connected_future.recover.flat_map { close_connections }
|
@@ -157,6 +159,18 @@ module Cassandra
|
|
157
159
|
end
|
158
160
|
end
|
159
161
|
|
162
|
+
def keyspace_created(keyspace)
|
163
|
+
end
|
164
|
+
|
165
|
+
def keyspace_changed(keyspace)
|
166
|
+
end
|
167
|
+
|
168
|
+
def keyspace_dropped(keyspace)
|
169
|
+
@keyspace = nil if @keyspace == keyspace.name
|
170
|
+
nil
|
171
|
+
end
|
172
|
+
|
173
|
+
|
160
174
|
def query(statement, options, paging_state = nil)
|
161
175
|
request = Protocol::QueryRequest.new(statement.cql, statement.params, nil, options.consistency, options.serial_consistency, options.page_size, paging_state, options.trace?)
|
162
176
|
timeout = options.timeout
|
@@ -340,7 +354,7 @@ module Cassandra
|
|
340
354
|
@connecting_hosts.delete(host)
|
341
355
|
@prepared_statements[host] = {}
|
342
356
|
@preparing_statements[host] = {}
|
343
|
-
manager = @connections[host] ||=
|
357
|
+
manager = @connections[host] ||= ConnectionPool.new
|
344
358
|
end
|
345
359
|
|
346
360
|
manager.add_connections(connections)
|
@@ -671,9 +685,7 @@ module Cassandra
|
|
671
685
|
when Protocol::RowsResultResponse
|
672
686
|
promise.fulfill(Results::Paged.new(r.rows, r.paging_state, r.trace_id, keyspace, statement, options, hosts, request.consistency, retries, self, @futures))
|
673
687
|
when Protocol::SchemaChangeResultResponse
|
674
|
-
if r.change == 'DROPPED' && r.
|
675
|
-
@keyspace = nil
|
676
|
-
end
|
688
|
+
@schema.delete_keyspace(r.keyspace) if r.change == 'DROPPED' && r.table.empty?
|
677
689
|
|
678
690
|
@logger.debug('Waiting for schema to propagate to all hosts after a change')
|
679
691
|
wait_for_schema_agreement(connection, @reconnection_policy.schedule).on_complete do |f|
|
@@ -17,14 +17,14 @@
|
|
17
17
|
#++
|
18
18
|
|
19
19
|
module Cassandra
|
20
|
-
|
20
|
+
class Cluster
|
21
21
|
# @private
|
22
|
-
class
|
22
|
+
class ConnectionPool
|
23
23
|
include Enumerable
|
24
24
|
|
25
25
|
def initialize
|
26
26
|
@connections = []
|
27
|
-
@lock = Mutex.new
|
27
|
+
@lock = ::Mutex.new
|
28
28
|
end
|
29
29
|
|
30
30
|
def add_connections(connections)
|
@@ -22,13 +22,14 @@ module Cassandra
|
|
22
22
|
class Connector
|
23
23
|
include MonitorMixin
|
24
24
|
|
25
|
-
def initialize(logger, io_reactor, cluster_registry, connection_options)
|
26
|
-
@logger
|
27
|
-
@reactor
|
28
|
-
@registry
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
25
|
+
def initialize(logger, io_reactor, cluster_registry, connection_options, execution_options)
|
26
|
+
@logger = logger
|
27
|
+
@reactor = io_reactor
|
28
|
+
@registry = cluster_registry
|
29
|
+
@connection_options = connection_options
|
30
|
+
@execution_options = execution_options
|
31
|
+
@connections = ::Hash.new
|
32
|
+
@open_connections = ::Hash.new
|
32
33
|
|
33
34
|
mon_initialize
|
34
35
|
end
|
@@ -115,13 +116,33 @@ module Cassandra
|
|
115
116
|
UNCLAIMED_TIMEOUT = 5 # close unclaimed connections in five seconds
|
116
117
|
|
117
118
|
def do_connect(host)
|
118
|
-
|
119
|
+
f = @reactor.connect(host.ip.to_s, @connection_options.port, {:timeout => @connection_options.connect_timeout, :ssl => @connection_options.ssl}) do |connection|
|
120
|
+
raise Errors::ClientError, 'Not connected, reactor stopped' unless connection
|
121
|
+
Protocol::CqlProtocolHandler.new(connection, @reactor, @connection_options.protocol_version, @connection_options.compressor, @connection_options.heartbeat_interval, @connection_options.idle_timeout)
|
122
|
+
end
|
123
|
+
f = f.flat_map do |connection|
|
124
|
+
request_options(connection).flat_map do |options|
|
125
|
+
compression = @connection_options.compression
|
126
|
+
supported_algorithms = options['COMPRESSION']
|
127
|
+
|
128
|
+
if compression && !supported_algorithms.include?(compression)
|
129
|
+
@logger.warn("Compression with #{compression.inspect} is not supported by host at #{host.ip}, supported algorithms are #{supported_algorithms.inspect}")
|
130
|
+
compression = nil
|
131
|
+
end
|
132
|
+
|
133
|
+
supported_cql_versions = options['CQL_VERSION']
|
134
|
+
cql_version = (supported_cql_versions && !supported_cql_versions.empty?) ? supported_cql_versions.first : '3.1.0'
|
135
|
+
|
136
|
+
startup_connection(connection, cql_version, compression)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
f.fallback do |error|
|
119
140
|
case error
|
120
141
|
when Errors::ProtocolError
|
121
142
|
synchronize do
|
122
|
-
if @
|
123
|
-
@logger.info("Host #{host.ip} doesn't support protocol version #{@
|
124
|
-
@
|
143
|
+
if @connection_options.protocol_version > 1
|
144
|
+
@logger.info("Host #{host.ip} doesn't support protocol version #{@connection_options.protocol_version}, downgrading")
|
145
|
+
@connection_options.protocol_version -= 1
|
125
146
|
do_connect(host)
|
126
147
|
else
|
127
148
|
Ione::Future.failed(error)
|
@@ -137,32 +158,82 @@ module Cassandra
|
|
137
158
|
end
|
138
159
|
end
|
139
160
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
161
|
+
def startup_connection(connection, cql_version, compression)
|
162
|
+
connection.send_request(Protocol::StartupRequest.new(cql_version, compression), @execution_options.timeout).flat_map do |r|
|
163
|
+
case r
|
164
|
+
when Protocol::AuthenticateResponse
|
165
|
+
if @connection_options.protocol_version == 1
|
166
|
+
credentials = @connection_options.credentials
|
167
|
+
if credentials
|
168
|
+
send_credentials(connection, credentials)
|
169
|
+
else
|
170
|
+
Ione::Future.failed(Errors::AuthenticationError.new('Server requested authentication, but client was not configured to authenticate'))
|
171
|
+
end
|
172
|
+
else
|
173
|
+
authenticator = @connection_options.create_authenticator(r.authentication_class)
|
174
|
+
if authenticator
|
175
|
+
challenge_response_cycle(connection, authenticator, authenticator.initial_response)
|
176
|
+
else
|
177
|
+
Ione::Future.failed(Errors::AuthenticationError.new('Server requested authentication, but client was not configured to authenticate'))
|
178
|
+
end
|
179
|
+
end
|
180
|
+
when Protocol::ReadyResponse
|
181
|
+
::Ione::Future.resolved(connection)
|
182
|
+
when Protocol::ErrorResponse
|
183
|
+
::Ione::Future.failed(r.to_error(VOID_STATEMENT))
|
184
|
+
else
|
185
|
+
::Ione::Future.failed(Errors::InternalError.new("Unexpected response #{r.inspect}"))
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def request_options(connection)
|
191
|
+
connection.send_request(Protocol::OptionsRequest.new, @execution_options.timeout).map do |r|
|
192
|
+
case r
|
193
|
+
when Protocol::SupportedResponse
|
194
|
+
r.options
|
195
|
+
when Protocol::ErrorResponse
|
196
|
+
raise r.to_error(VOID_STATEMENT)
|
197
|
+
else
|
198
|
+
raise Errors::InternalError, "Unexpected response #{r.inspect}"
|
199
|
+
end
|
145
200
|
end
|
201
|
+
end
|
146
202
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
203
|
+
def send_credentials(connection, credentials)
|
204
|
+
connection.send_request(Protocol::CredentialsRequest.new(credentials), @execution_options.timeout).map do |r|
|
205
|
+
case r
|
206
|
+
when Protocol::ReadyResponse
|
207
|
+
connection
|
208
|
+
when Protocol::ErrorResponse
|
209
|
+
raise r.to_error(VOID_STATEMENT)
|
210
|
+
else
|
211
|
+
raise Errors::InternalError, "Unexpected response #{r.inspect}"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def challenge_response_cycle(connection, authenticator, token)
|
217
|
+
connection.send_request(Protocol::AuthResponseRequest.new(token), @execution_options.timeout).flat_map do |r|
|
218
|
+
case r
|
219
|
+
when Protocol::AuthChallengeResponse
|
220
|
+
token = authenticator.challenge_response(r.token)
|
221
|
+
challenge_response_cycle(pending_connection, authenticator, token)
|
222
|
+
when Protocol::AuthSuccessResponse
|
223
|
+
authenticator.authentication_successful(r.token) rescue nil
|
224
|
+
::Ione::Future.resolved(connection)
|
225
|
+
when Protocol::ErrorResponse
|
226
|
+
::Ione::Future.failed(r.to_error(VOID_STATEMENT))
|
227
|
+
else
|
228
|
+
::Ione::Future.failed(Errors::InternalError.new("Unexpected response #{r.inspect}"))
|
229
|
+
end
|
230
|
+
end
|
160
231
|
end
|
161
232
|
|
162
233
|
def create_additional_connections(host, count, established_connections, error = nil)
|
163
234
|
futures = count.times.map do
|
164
235
|
connect(host).recover do |e|
|
165
|
-
|
236
|
+
FailedConnection.new(e, host)
|
166
237
|
end
|
167
238
|
end
|
168
239
|
|
@@ -333,10 +333,9 @@ module Cassandra
|
|
333
333
|
|
334
334
|
return Ione::Future.failed(Errors::ClientError.new('Not connected')) if connection.nil?
|
335
335
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name = ?", params, nil, :one))
|
336
|
+
keyspaces = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_keyspaces WHERE keyspace_name = '%s'" % keyspace, nil, nil, :one))
|
337
|
+
tables = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columnfamilies WHERE keyspace_name = '%s'" % keyspace, nil, nil, :one))
|
338
|
+
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name = '%s'" % keyspace, nil, nil, :one))
|
340
339
|
|
341
340
|
Ione::Future.all(keyspaces, tables, columns).map do |(keyspaces, tables, columns)|
|
342
341
|
host = @registry.host(connection.host)
|
@@ -396,8 +395,8 @@ module Cassandra
|
|
396
395
|
return Ione::Future.failed(Errors::ClientError.new('Not connected')) if connection.nil?
|
397
396
|
|
398
397
|
params = [keyspace, table]
|
399
|
-
table = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columnfamilies WHERE keyspace_name =
|
400
|
-
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name =
|
398
|
+
table = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columnfamilies WHERE keyspace_name = '%s' AND columnfamily_name = '%s'" % params, nil, nil, :one))
|
399
|
+
columns = send_select_request(connection, Protocol::QueryRequest.new("SELECT * FROM system.schema_columns WHERE keyspace_name = '%s' AND columnfamily_name = '%s'" % params, nil, nil, :one))
|
401
400
|
|
402
401
|
Ione::Future.all(table, columns).map do |(table, columns)|
|
403
402
|
host = @registry.host(connection.host)
|
@@ -563,7 +562,7 @@ module Cassandra
|
|
563
562
|
if ip == connection.host
|
564
563
|
request = SELECT_LOCAL
|
565
564
|
else
|
566
|
-
request = Protocol::QueryRequest.new(
|
565
|
+
request = Protocol::QueryRequest.new("SELECT rack, data_center, host_id, rpc_address, release_version, tokens FROM system.peers WHERE peer = '%s'" % address, nil, nil, :one)
|
567
566
|
end
|
568
567
|
|
569
568
|
send_select_request(connection, request).map do |rows|
|
@@ -17,21 +17,19 @@
|
|
17
17
|
#++
|
18
18
|
|
19
19
|
module Cassandra
|
20
|
-
|
20
|
+
class Cluster
|
21
21
|
# @private
|
22
|
-
class
|
23
|
-
|
24
|
-
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
def warn(*); end
|
34
|
-
def warn?; false end
|
22
|
+
class FailedConnection
|
23
|
+
attr_reader :error, :host
|
24
|
+
|
25
|
+
def initialize(error, host)
|
26
|
+
@error = error
|
27
|
+
@host = host
|
28
|
+
end
|
29
|
+
|
30
|
+
def connected?
|
31
|
+
false
|
32
|
+
end
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
@@ -40,6 +40,14 @@ module Cassandra
|
|
40
40
|
@connections_per_local_node = connections_per_local_node
|
41
41
|
@connections_per_remote_node = connections_per_remote_node
|
42
42
|
end
|
43
|
+
|
44
|
+
def compression
|
45
|
+
@compressor && @compressor.algorithm
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_authenticator(authentication_class)
|
49
|
+
@auth_provider && @auth_provider.create_authenticator(authentication_class)
|
50
|
+
end
|
43
51
|
end
|
44
52
|
end
|
45
53
|
end
|
data/lib/cassandra/column.rb
CHANGED
@@ -78,6 +78,11 @@ module Cassandra
|
|
78
78
|
cql
|
79
79
|
end
|
80
80
|
|
81
|
+
# @return [String] a CLI-friendly column representation
|
82
|
+
def inspect
|
83
|
+
"#<#{self.class.name}:0x#{self.object_id.to_s(16)} @name=#{@name}>"
|
84
|
+
end
|
85
|
+
|
81
86
|
# @return [Boolean] whether this column is equal to the other
|
82
87
|
def eql?(other)
|
83
88
|
other.is_a?(Column) &&
|
data/lib/cassandra/driver.rb
CHANGED
@@ -54,7 +54,7 @@ module Cassandra
|
|
54
54
|
let(:ordered_partitioner) { Cluster::Schema::Partitioners::Ordered.new }
|
55
55
|
let(:random_partitioner) { Cluster::Schema::Partitioners::Random.new }
|
56
56
|
|
57
|
-
let(:connector) { Cluster::Connector.new(logger, io_reactor, cluster_registry, connection_options) }
|
57
|
+
let(:connector) { Cluster::Connector.new(logger, io_reactor, cluster_registry, connection_options, execution_options) }
|
58
58
|
|
59
59
|
let(:control_connection) { Cluster::ControlConnection.new(logger, io_reactor, cluster_registry, cluster_schema, cluster_metadata, load_balancing_policy, reconnection_policy, address_resolution_policy, connector) }
|
60
60
|
|
@@ -75,7 +75,7 @@ module Cassandra
|
|
75
75
|
let(:protocol_version) { 2 }
|
76
76
|
let(:connect_timeout) { 10 }
|
77
77
|
let(:ssl) { false }
|
78
|
-
let(:logger) {
|
78
|
+
let(:logger) { NullLogger.new }
|
79
79
|
let(:compressor) { nil }
|
80
80
|
let(:credentials) { nil }
|
81
81
|
let(:auth_provider) { nil }
|
@@ -86,7 +86,7 @@ module Cassandra
|
|
86
86
|
let(:address_resolution_policy) { AddressResolution::Policies::None.new }
|
87
87
|
let(:consistency) { :one }
|
88
88
|
let(:trace) { false }
|
89
|
-
let(:page_size) {
|
89
|
+
let(:page_size) { 10000 }
|
90
90
|
let(:heartbeat_interval) { 30 }
|
91
91
|
let(:idle_timeout) { 60 }
|
92
92
|
let(:timeout) { 10 }
|
data/lib/cassandra/errors.rb
CHANGED
@@ -49,28 +49,28 @@ module Cassandra
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# Mixed into all internal driver errors.
|
52
|
-
|
52
|
+
class InternalError < ::RuntimeError
|
53
53
|
include Error, HostError
|
54
54
|
end
|
55
55
|
|
56
56
|
# Raised when data decoding fails.
|
57
57
|
class DecodingError < ::RuntimeError
|
58
|
-
include
|
58
|
+
include Error, HostError
|
59
59
|
end
|
60
60
|
|
61
61
|
# Raised when data encoding fails.
|
62
62
|
class EncodingError < ::RuntimeError
|
63
|
-
include
|
63
|
+
include Error, HostError
|
64
64
|
end
|
65
65
|
|
66
66
|
# Raised when a connection level error occured.
|
67
67
|
class IOError < ::IOError
|
68
|
-
include
|
68
|
+
include Error, HostError
|
69
69
|
end
|
70
70
|
|
71
71
|
# Raised when a timeout has occured.
|
72
72
|
class TimeoutError < ::Timeout::Error
|
73
|
-
include
|
73
|
+
include Error, HostError
|
74
74
|
end
|
75
75
|
|
76
76
|
# Mixed into all request execution errors.
|
@@ -39,14 +39,21 @@ module Cassandra
|
|
39
39
|
timeout = options[:timeout]
|
40
40
|
serial_consistency = options[:serial_consistency]
|
41
41
|
|
42
|
-
|
43
|
-
raise ::ArgumentError, ":serial_consistency must be one of #{SERIAL_CONSISTENCIES.inspect}, #{serial_consistency.inspect} given" if serial_consistency && !SERIAL_CONSISTENCIES.include?(serial_consistency)
|
42
|
+
Util.assert_one_of(CONSISTENCIES, consistency) { ":consistency must be one of #{CONSISTENCIES.inspect}, #{consistency.inspect} given" }
|
44
43
|
|
45
|
-
|
46
|
-
|
44
|
+
unless serial_consistency.nil?
|
45
|
+
Util.assert_one_of(SERIAL_CONSISTENCIES, serial_consistency) { ":serial_consistency must be one of #{SERIAL_CONSISTENCIES.inspect}, #{serial_consistency.inspect} given" }
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
unless page_size.nil?
|
49
|
+
page_size = options[:page_size] = Integer(page_size)
|
50
|
+
Util.assert(page_size > 0) { ":page_size must be a positive integer, #{page_size.inspect} given" }
|
51
|
+
end
|
52
|
+
|
53
|
+
unless timeout.nil?
|
54
|
+
Util.assert_instance_of(::Numeric, timeout) { ":timeout must be a number of seconds, #{timeout} given" }
|
55
|
+
Util.assert(timeout > 0) { ":timeout must be greater than 0, #{timeout} given" }
|
56
|
+
end
|
50
57
|
|
51
58
|
@consistency = consistency
|
52
59
|
@page_size = page_size
|
@@ -108,16 +108,16 @@ module Cassandra
|
|
108
108
|
private
|
109
109
|
|
110
110
|
# @private
|
111
|
-
SELECT_SESSION = "SELECT * FROM system_traces.sessions WHERE session_id =
|
111
|
+
SELECT_SESSION = "SELECT * FROM system_traces.sessions WHERE session_id = %s"
|
112
112
|
# @private
|
113
|
-
SELECT_EVENTS = "SELECT * FROM system_traces.events WHERE session_id =
|
113
|
+
SELECT_EVENTS = "SELECT * FROM system_traces.events WHERE session_id = %s"
|
114
114
|
|
115
115
|
# @private
|
116
116
|
def load
|
117
117
|
synchronize do
|
118
118
|
return if @loaded
|
119
119
|
|
120
|
-
data = @client.query(Statements::Simple.new(SELECT_SESSION
|
120
|
+
data = @client.query(Statements::Simple.new(SELECT_SESSION % @id), VOID_OPTIONS).get.first
|
121
121
|
raise ::RuntimeError, "unable to load trace #{@id}" if data.nil?
|
122
122
|
|
123
123
|
@coordinator = data['coordinator']
|
@@ -138,7 +138,7 @@ module Cassandra
|
|
138
138
|
|
139
139
|
@events = []
|
140
140
|
|
141
|
-
@client.query(Statements::Simple.new(SELECT_EVENTS
|
141
|
+
@client.query(Statements::Simple.new(SELECT_EVENTS % @id), VOID_OPTIONS).get.each do |row|
|
142
142
|
@events << Event.new(row['event_id'], row['activity'], row['source'], row['source_elapsed'], row['thread'])
|
143
143
|
end
|
144
144
|
|