yugabyte-ycql-driver 3.2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +13 -0
- data/README.md +242 -0
- data/ext/cassandra_murmur3/cassandra_murmur3.c +178 -0
- data/ext/cassandra_murmur3/extconf.rb +2 -0
- data/lib/cassandra/address_resolution.rb +36 -0
- data/lib/cassandra/address_resolution/policies.rb +2 -0
- data/lib/cassandra/address_resolution/policies/ec2_multi_region.rb +56 -0
- data/lib/cassandra/address_resolution/policies/none.rb +35 -0
- data/lib/cassandra/aggregate.rb +123 -0
- data/lib/cassandra/argument.rb +51 -0
- data/lib/cassandra/attr_boolean.rb +33 -0
- data/lib/cassandra/auth.rb +100 -0
- data/lib/cassandra/auth/providers.rb +17 -0
- data/lib/cassandra/auth/providers/password.rb +65 -0
- data/lib/cassandra/cassandra_logger.rb +80 -0
- data/lib/cassandra/cluster.rb +331 -0
- data/lib/cassandra/cluster/client.rb +1612 -0
- data/lib/cassandra/cluster/connection_pool.rb +78 -0
- data/lib/cassandra/cluster/connector.rb +372 -0
- data/lib/cassandra/cluster/control_connection.rb +962 -0
- data/lib/cassandra/cluster/failed_connection.rb +35 -0
- data/lib/cassandra/cluster/metadata.rb +142 -0
- data/lib/cassandra/cluster/options.rb +145 -0
- data/lib/cassandra/cluster/registry.rb +284 -0
- data/lib/cassandra/cluster/schema.rb +405 -0
- data/lib/cassandra/cluster/schema/cql_type_parser.rb +112 -0
- data/lib/cassandra/cluster/schema/fetchers.rb +1627 -0
- data/lib/cassandra/cluster/schema/fqcn_type_parser.rb +175 -0
- data/lib/cassandra/cluster/schema/partitioners.rb +21 -0
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +45 -0
- data/lib/cassandra/cluster/schema/partitioners/ordered.rb +37 -0
- data/lib/cassandra/cluster/schema/partitioners/random.rb +37 -0
- data/lib/cassandra/cluster/schema/replication_strategies.rb +21 -0
- data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +102 -0
- data/lib/cassandra/cluster/schema/replication_strategies/none.rb +39 -0
- data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +44 -0
- data/lib/cassandra/column.rb +66 -0
- data/lib/cassandra/column_container.rb +326 -0
- data/lib/cassandra/compression.rb +69 -0
- data/lib/cassandra/compression/compressors/lz4.rb +73 -0
- data/lib/cassandra/compression/compressors/snappy.rb +69 -0
- data/lib/cassandra/custom_data.rb +53 -0
- data/lib/cassandra/driver.rb +260 -0
- data/lib/cassandra/errors.rb +784 -0
- data/lib/cassandra/execution/info.rb +69 -0
- data/lib/cassandra/execution/options.rb +267 -0
- data/lib/cassandra/execution/profile.rb +153 -0
- data/lib/cassandra/execution/profile_manager.rb +71 -0
- data/lib/cassandra/execution/trace.rb +192 -0
- data/lib/cassandra/executors.rb +113 -0
- data/lib/cassandra/function.rb +156 -0
- data/lib/cassandra/function_collection.rb +85 -0
- data/lib/cassandra/future.rb +794 -0
- data/lib/cassandra/host.rb +102 -0
- data/lib/cassandra/index.rb +118 -0
- data/lib/cassandra/keyspace.rb +473 -0
- data/lib/cassandra/listener.rb +87 -0
- data/lib/cassandra/load_balancing.rb +121 -0
- data/lib/cassandra/load_balancing/policies.rb +20 -0
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +172 -0
- data/lib/cassandra/load_balancing/policies/round_robin.rb +141 -0
- data/lib/cassandra/load_balancing/policies/token_aware.rb +149 -0
- data/lib/cassandra/load_balancing/policies/white_list.rb +100 -0
- data/lib/cassandra/materialized_view.rb +92 -0
- data/lib/cassandra/null_logger.rb +56 -0
- data/lib/cassandra/protocol.rb +102 -0
- data/lib/cassandra/protocol/coder.rb +1085 -0
- data/lib/cassandra/protocol/cql_byte_buffer.rb +418 -0
- data/lib/cassandra/protocol/cql_protocol_handler.rb +448 -0
- data/lib/cassandra/protocol/request.rb +41 -0
- data/lib/cassandra/protocol/requests/auth_response_request.rb +51 -0
- data/lib/cassandra/protocol/requests/batch_request.rb +117 -0
- data/lib/cassandra/protocol/requests/credentials_request.rb +51 -0
- data/lib/cassandra/protocol/requests/execute_request.rb +122 -0
- data/lib/cassandra/protocol/requests/options_request.rb +39 -0
- data/lib/cassandra/protocol/requests/prepare_request.rb +59 -0
- data/lib/cassandra/protocol/requests/query_request.rb +112 -0
- data/lib/cassandra/protocol/requests/register_request.rb +38 -0
- data/lib/cassandra/protocol/requests/startup_request.rb +49 -0
- data/lib/cassandra/protocol/requests/void_query_request.rb +24 -0
- data/lib/cassandra/protocol/response.rb +28 -0
- data/lib/cassandra/protocol/responses/already_exists_error_response.rb +50 -0
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +36 -0
- data/lib/cassandra/protocol/responses/auth_success_response.rb +36 -0
- data/lib/cassandra/protocol/responses/authenticate_response.rb +36 -0
- data/lib/cassandra/protocol/responses/error_response.rb +142 -0
- data/lib/cassandra/protocol/responses/event_response.rb +30 -0
- data/lib/cassandra/protocol/responses/function_failure_error_response.rb +52 -0
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +62 -0
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +59 -0
- data/lib/cassandra/protocol/responses/read_failure_error_response.rb +71 -0
- data/lib/cassandra/protocol/responses/read_timeout_error_response.rb +61 -0
- data/lib/cassandra/protocol/responses/ready_response.rb +43 -0
- data/lib/cassandra/protocol/responses/result_response.rb +42 -0
- data/lib/cassandra/protocol/responses/rows_result_response.rb +39 -0
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +73 -0
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +70 -0
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +37 -0
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +39 -0
- data/lib/cassandra/protocol/responses/supported_response.rb +36 -0
- data/lib/cassandra/protocol/responses/topology_change_event_response.rb +33 -0
- data/lib/cassandra/protocol/responses/unavailable_error_response.rb +58 -0
- data/lib/cassandra/protocol/responses/unprepared_error_response.rb +48 -0
- data/lib/cassandra/protocol/responses/void_result_response.rb +34 -0
- data/lib/cassandra/protocol/responses/write_failure_error_response.rb +73 -0
- data/lib/cassandra/protocol/responses/write_timeout_error_response.rb +63 -0
- data/lib/cassandra/protocol/v1.rb +326 -0
- data/lib/cassandra/protocol/v3.rb +358 -0
- data/lib/cassandra/protocol/v4.rb +478 -0
- data/lib/cassandra/reconnection.rb +49 -0
- data/lib/cassandra/reconnection/policies.rb +20 -0
- data/lib/cassandra/reconnection/policies/constant.rb +46 -0
- data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
- data/lib/cassandra/result.rb +276 -0
- data/lib/cassandra/retry.rb +154 -0
- data/lib/cassandra/retry/policies.rb +21 -0
- data/lib/cassandra/retry/policies/default.rb +53 -0
- data/lib/cassandra/retry/policies/downgrading_consistency.rb +73 -0
- data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
- data/lib/cassandra/session.rb +270 -0
- data/lib/cassandra/statement.rb +32 -0
- data/lib/cassandra/statements.rb +23 -0
- data/lib/cassandra/statements/batch.rb +146 -0
- data/lib/cassandra/statements/bound.rb +65 -0
- data/lib/cassandra/statements/prepared.rb +235 -0
- data/lib/cassandra/statements/simple.rb +118 -0
- data/lib/cassandra/statements/void.rb +38 -0
- data/lib/cassandra/table.rb +240 -0
- data/lib/cassandra/time.rb +103 -0
- data/lib/cassandra/time_uuid.rb +78 -0
- data/lib/cassandra/timestamp_generator.rb +37 -0
- data/lib/cassandra/timestamp_generator/simple.rb +38 -0
- data/lib/cassandra/timestamp_generator/ticking_on_duplicate.rb +58 -0
- data/lib/cassandra/trigger.rb +67 -0
- data/lib/cassandra/tuple.rb +131 -0
- data/lib/cassandra/types.rb +1704 -0
- data/lib/cassandra/udt.rb +443 -0
- data/lib/cassandra/util.rb +464 -0
- data/lib/cassandra/uuid.rb +110 -0
- data/lib/cassandra/uuid/generator.rb +212 -0
- data/lib/cassandra/version.rb +21 -0
- data/lib/datastax/cassandra.rb +47 -0
- data/lib/ycql.rb +842 -0
- metadata +243 -0
@@ -0,0 +1,784 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Copyright DataStax, Inc.
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#++
|
18
|
+
|
19
|
+
module Cassandra
|
20
|
+
# Included in all Errors raised by the driver to allow rescuing from any
|
21
|
+
# driver-specific error.
|
22
|
+
# @example Catching all driver errors
|
23
|
+
# begin
|
24
|
+
# cluster = Cassandra.cluster
|
25
|
+
# session = cluster.connect
|
26
|
+
# rescue Cassandra::Error => e
|
27
|
+
# puts "#{e.class.name}: #{e.message}"
|
28
|
+
# end
|
29
|
+
# @see Cassandra::Errors
|
30
|
+
module Error
|
31
|
+
end
|
32
|
+
|
33
|
+
module Errors
|
34
|
+
# Mixed into any host-specific errors. Requests resulting in these errors
|
35
|
+
# are attempted on other hosts. Once all hosts failed with this type of
|
36
|
+
# error, a {Cassandra::Errors::NoHostsAvailable} error is raised with
|
37
|
+
# details of failures.
|
38
|
+
#
|
39
|
+
# @see Errors::NoHostsAvailable
|
40
|
+
module HostError
|
41
|
+
end
|
42
|
+
|
43
|
+
# Raised when something unexpected happened. This indicates a server-side
|
44
|
+
# bug.
|
45
|
+
#
|
46
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L654-L655 Description
|
47
|
+
# of Server Error in Apache Cassandra native protocol spec v1
|
48
|
+
class ServerError < ::StandardError
|
49
|
+
include Error, HostError
|
50
|
+
|
51
|
+
# @private
|
52
|
+
def initialize(message,
|
53
|
+
payload,
|
54
|
+
warnings,
|
55
|
+
keyspace,
|
56
|
+
statement,
|
57
|
+
options,
|
58
|
+
hosts,
|
59
|
+
consistency,
|
60
|
+
retries)
|
61
|
+
super(message)
|
62
|
+
@payload = payload
|
63
|
+
@warnings = warnings
|
64
|
+
@keyspace = keyspace
|
65
|
+
@statement = statement
|
66
|
+
@options = options
|
67
|
+
@hosts = hosts
|
68
|
+
@consistency = consistency
|
69
|
+
@retries = retries
|
70
|
+
end
|
71
|
+
|
72
|
+
# Query execution information, such as number of retries and all tried hosts, etc.
|
73
|
+
# @return [Cassandra::Execution::Info]
|
74
|
+
def execution_info
|
75
|
+
@info ||= Execution::Info.new(@payload,
|
76
|
+
@warnings,
|
77
|
+
@keyspace,
|
78
|
+
@statement,
|
79
|
+
@options,
|
80
|
+
@hosts,
|
81
|
+
@consistency,
|
82
|
+
@retries,
|
83
|
+
nil)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Mixed into all internal driver errors.
|
88
|
+
class InternalError < ::RuntimeError
|
89
|
+
include Error, HostError
|
90
|
+
end
|
91
|
+
|
92
|
+
# Raised when data decoding fails.
|
93
|
+
class DecodingError < ::RuntimeError
|
94
|
+
include Error, HostError
|
95
|
+
end
|
96
|
+
|
97
|
+
# Raised when data encoding fails.
|
98
|
+
class EncodingError < ::RuntimeError
|
99
|
+
include Error, HostError
|
100
|
+
end
|
101
|
+
|
102
|
+
# Raised when a connection level error occured.
|
103
|
+
class IOError < ::IOError
|
104
|
+
include Error, HostError
|
105
|
+
end
|
106
|
+
|
107
|
+
# Raised when a timeout has occured.
|
108
|
+
class TimeoutError < ::Timeout::Error
|
109
|
+
include Error
|
110
|
+
end
|
111
|
+
|
112
|
+
# Mixed into all request execution errors.
|
113
|
+
module ExecutionError
|
114
|
+
include Error
|
115
|
+
|
116
|
+
# @private
|
117
|
+
def initialize(message,
|
118
|
+
payload,
|
119
|
+
warnings,
|
120
|
+
keyspace,
|
121
|
+
statement,
|
122
|
+
options,
|
123
|
+
hosts,
|
124
|
+
consistency,
|
125
|
+
retries)
|
126
|
+
super(message)
|
127
|
+
@payload = payload
|
128
|
+
@warnings = warnings
|
129
|
+
@keyspace = keyspace
|
130
|
+
@statement = statement
|
131
|
+
@options = options
|
132
|
+
@hosts = hosts
|
133
|
+
@consistency = consistency
|
134
|
+
@retries = retries
|
135
|
+
end
|
136
|
+
|
137
|
+
# Query execution information, such as number of retries and all tried hosts, etc.
|
138
|
+
# @return [Cassandra::Execution::Info]
|
139
|
+
def execution_info
|
140
|
+
@info ||= Execution::Info.new(@payload,
|
141
|
+
@warnings,
|
142
|
+
@keyspace,
|
143
|
+
@statement,
|
144
|
+
@options,
|
145
|
+
@hosts,
|
146
|
+
@consistency,
|
147
|
+
@retries,
|
148
|
+
nil)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Raised when coordinator determines that a request cannot be executed
|
153
|
+
# because there are not enough replicas. In this scenario, the request is
|
154
|
+
# not sent to the nodes at all.
|
155
|
+
#
|
156
|
+
# @note This error can be handled by a {Cassandra::Retry::Policy} to
|
157
|
+
# determine the desired outcome.
|
158
|
+
#
|
159
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L662-L672 Description
|
160
|
+
# of Unavailable Error in Apache Cassandra native protocol spec v1
|
161
|
+
class UnavailableError < ::StandardError
|
162
|
+
include ExecutionError
|
163
|
+
# Consistency level that triggered the error.
|
164
|
+
#
|
165
|
+
# @return [Symbol] the original consistency level for the request, one of
|
166
|
+
# {Cassandra::CONSISTENCIES}
|
167
|
+
attr_reader :consistency
|
168
|
+
|
169
|
+
# @return [Integer] the number of replicas required to achieve requested
|
170
|
+
# consistency level
|
171
|
+
attr_reader :required
|
172
|
+
|
173
|
+
# @return [Integer] the number of replicas available for the request
|
174
|
+
attr_reader :alive
|
175
|
+
|
176
|
+
# @private
|
177
|
+
def initialize(message,
|
178
|
+
payload,
|
179
|
+
warnings,
|
180
|
+
keyspace,
|
181
|
+
statement,
|
182
|
+
options,
|
183
|
+
hosts,
|
184
|
+
r_consistency,
|
185
|
+
retries,
|
186
|
+
consistency,
|
187
|
+
required,
|
188
|
+
alive)
|
189
|
+
super(message,
|
190
|
+
payload,
|
191
|
+
warnings,
|
192
|
+
keyspace,
|
193
|
+
statement,
|
194
|
+
options,
|
195
|
+
hosts,
|
196
|
+
r_consistency,
|
197
|
+
retries)
|
198
|
+
@consistency = consistency
|
199
|
+
@required = required
|
200
|
+
@alive = alive
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
# Raised when the request cannot be processed because the coordinator node
|
205
|
+
# is overloaded
|
206
|
+
#
|
207
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L673-L674 Description
|
208
|
+
# of Overloaded Error in Apache Cassandra native protocol spec v1
|
209
|
+
class OverloadedError < ::StandardError
|
210
|
+
include ExecutionError, HostError
|
211
|
+
end
|
212
|
+
|
213
|
+
# Raise when the request was a read request but the coordinator node is
|
214
|
+
# bootstrapping
|
215
|
+
#
|
216
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L675-L676 Description
|
217
|
+
# of Is Bootstrapping Error in Apache Cassandra native protocol spec v1
|
218
|
+
class IsBootstrappingError < ::StandardError
|
219
|
+
include ExecutionError, HostError
|
220
|
+
end
|
221
|
+
|
222
|
+
# Raised when truncation failed.
|
223
|
+
#
|
224
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L677 Description of
|
225
|
+
# Truncate Error in Apache Cassandra native protocol spec v1
|
226
|
+
class TruncateError < ::StandardError
|
227
|
+
include ExecutionError
|
228
|
+
end
|
229
|
+
|
230
|
+
# Raised when a write request timed out.
|
231
|
+
#
|
232
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L678-L703 Description
|
233
|
+
# of Write Timeout Error in Apache Cassandra native protocol spec v1
|
234
|
+
class WriteTimeoutError < ::StandardError
|
235
|
+
include ExecutionError
|
236
|
+
|
237
|
+
# @return [Symbol] the type of write request that timed out, one of
|
238
|
+
# {Cassandra::WRITE_TYPES}
|
239
|
+
attr_reader :type
|
240
|
+
# @return [Symbol] the original consistency level for the request, one of
|
241
|
+
# {Cassandra::CONSISTENCIES}
|
242
|
+
attr_reader :consistency
|
243
|
+
# @return [Integer] the number of acks required to achieve requested
|
244
|
+
# consistency level
|
245
|
+
attr_reader :required
|
246
|
+
# @return [Integer] the number of acks received by the time the query
|
247
|
+
# timed out
|
248
|
+
attr_reader :received
|
249
|
+
|
250
|
+
# @private
|
251
|
+
def initialize(message,
|
252
|
+
payload,
|
253
|
+
warnings,
|
254
|
+
keyspace,
|
255
|
+
statement,
|
256
|
+
options,
|
257
|
+
hosts,
|
258
|
+
r_consistency,
|
259
|
+
retries,
|
260
|
+
type,
|
261
|
+
consistency,
|
262
|
+
required,
|
263
|
+
received)
|
264
|
+
super(message,
|
265
|
+
payload,
|
266
|
+
warnings,
|
267
|
+
keyspace,
|
268
|
+
statement,
|
269
|
+
options,
|
270
|
+
hosts,
|
271
|
+
r_consistency,
|
272
|
+
retries)
|
273
|
+
@type = type
|
274
|
+
@consistency = consistency
|
275
|
+
@required = required
|
276
|
+
@received = received
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
# Raised when a read request timed out.
|
281
|
+
#
|
282
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L704-L721 Description
|
283
|
+
# of Read Timeout Error in Apache Cassandra native protocol spec v1
|
284
|
+
class ReadTimeoutError < ::StandardError
|
285
|
+
include ExecutionError
|
286
|
+
|
287
|
+
# @return [Boolean] whether actual data (as opposed to data checksum) was
|
288
|
+
# present in the received responses.
|
289
|
+
attr_reader :retrieved
|
290
|
+
alias retrieved? retrieved
|
291
|
+
|
292
|
+
# @return [Symbol] the original consistency level for the request, one of
|
293
|
+
# {Cassandra::CONSISTENCIES}
|
294
|
+
attr_reader :consistency
|
295
|
+
# @return [Integer] the number of responses required to achieve requested
|
296
|
+
# consistency level
|
297
|
+
attr_reader :required
|
298
|
+
# @return [Integer] the number of responses received by the time the
|
299
|
+
# query timed out
|
300
|
+
attr_reader :received
|
301
|
+
|
302
|
+
# @private
|
303
|
+
def initialize(message,
|
304
|
+
payload,
|
305
|
+
warnings,
|
306
|
+
keyspace,
|
307
|
+
statement,
|
308
|
+
options,
|
309
|
+
hosts,
|
310
|
+
r_consistency,
|
311
|
+
retries,
|
312
|
+
retrieved,
|
313
|
+
consistency,
|
314
|
+
required,
|
315
|
+
received)
|
316
|
+
super(message,
|
317
|
+
payload,
|
318
|
+
warnings,
|
319
|
+
keyspace,
|
320
|
+
statement,
|
321
|
+
options,
|
322
|
+
hosts,
|
323
|
+
r_consistency,
|
324
|
+
retries)
|
325
|
+
@retrieved = retrieved
|
326
|
+
@consistency = consistency
|
327
|
+
@required = required
|
328
|
+
@received = received
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
# Raised when a write request fails.
|
333
|
+
#
|
334
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-3.4/doc/native_protocol_v4.spec#L1106-L1134 Description
|
335
|
+
# of Write Failure Error in Apache Cassandra native protocol spec v4
|
336
|
+
class WriteError < ::StandardError
|
337
|
+
include ExecutionError
|
338
|
+
|
339
|
+
# @return [Symbol] the type of write request that timed out, one of
|
340
|
+
# {Cassandra::WRITE_TYPES}
|
341
|
+
attr_reader :type
|
342
|
+
# @return [Symbol] the original consistency level for the request, one of
|
343
|
+
# {Cassandra::CONSISTENCIES}
|
344
|
+
attr_reader :consistency
|
345
|
+
# @return [Integer] the number of acks required
|
346
|
+
attr_reader :required
|
347
|
+
# @return [Integer] the number of acks received
|
348
|
+
attr_reader :received
|
349
|
+
# @return [Integer] the number of writes failed
|
350
|
+
attr_reader :failed
|
351
|
+
# @return [Hash<IPAddr, Integer>] map of <ip, error-code>. This is new in v5 and is nil in previous versions
|
352
|
+
# of the Casssandra protocol.
|
353
|
+
attr_reader :failures_by_node
|
354
|
+
|
355
|
+
# @private
|
356
|
+
def initialize(message,
|
357
|
+
payload,
|
358
|
+
warnings,
|
359
|
+
keyspace,
|
360
|
+
statement,
|
361
|
+
options,
|
362
|
+
hosts,
|
363
|
+
r_consistency,
|
364
|
+
retries,
|
365
|
+
type,
|
366
|
+
consistency,
|
367
|
+
required,
|
368
|
+
failed,
|
369
|
+
received,
|
370
|
+
failures_by_node)
|
371
|
+
super(message,
|
372
|
+
payload,
|
373
|
+
warnings,
|
374
|
+
keyspace,
|
375
|
+
statement,
|
376
|
+
options,
|
377
|
+
hosts,
|
378
|
+
r_consistency,
|
379
|
+
retries)
|
380
|
+
@type = type
|
381
|
+
@consistency = consistency
|
382
|
+
@required = required
|
383
|
+
@failed = failed
|
384
|
+
@received = received
|
385
|
+
@failures_by_node = failures_by_node
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
# Raised when a read request fails.
|
390
|
+
#
|
391
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-3.4/doc/native_protocol_v4.spec#L1084-L1098 Description
|
392
|
+
# of Read Failure Error in Apache Cassandra native protocol spec v4
|
393
|
+
class ReadError < ::StandardError
|
394
|
+
include ExecutionError
|
395
|
+
|
396
|
+
# @return [Boolean] whether actual data (as opposed to data checksum) was
|
397
|
+
# present in the received responses.
|
398
|
+
attr_reader :retrieved
|
399
|
+
# @return [Symbol] the original consistency level for the request, one of
|
400
|
+
# {Cassandra::CONSISTENCIES}
|
401
|
+
attr_reader :consistency
|
402
|
+
# @return [Integer] the number of responses required
|
403
|
+
attr_reader :required
|
404
|
+
# @return [Integer] the number of responses received
|
405
|
+
attr_reader :received
|
406
|
+
# @return [Integer] the number of reads failed
|
407
|
+
attr_reader :failed
|
408
|
+
# @return [Hash<IPaddr, Integer>] map of <ip, error-code>. This is new in v5 and is nil in previous versions
|
409
|
+
# of the Casssandra protocol.
|
410
|
+
attr_reader :failures_by_node
|
411
|
+
|
412
|
+
# @private
|
413
|
+
def initialize(message,
|
414
|
+
payload,
|
415
|
+
warnings,
|
416
|
+
keyspace,
|
417
|
+
statement,
|
418
|
+
options,
|
419
|
+
hosts,
|
420
|
+
r_consistency,
|
421
|
+
retries,
|
422
|
+
retrieved,
|
423
|
+
consistency,
|
424
|
+
required,
|
425
|
+
failed,
|
426
|
+
received,
|
427
|
+
failures_by_node)
|
428
|
+
super(message,
|
429
|
+
payload,
|
430
|
+
warnings,
|
431
|
+
keyspace,
|
432
|
+
statement,
|
433
|
+
options,
|
434
|
+
hosts,
|
435
|
+
r_consistency,
|
436
|
+
retries)
|
437
|
+
@retrieved = retrieved
|
438
|
+
@consistency = consistency
|
439
|
+
@required = required
|
440
|
+
@failed = failed
|
441
|
+
@received = received
|
442
|
+
@failures_by_node = failures_by_node
|
443
|
+
end
|
444
|
+
|
445
|
+
def retrieved?
|
446
|
+
@retrieved
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
# Raised when function execution fails.
|
451
|
+
#
|
452
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-3.4/doc/native_protocol_v4.spec#L1099-L1105 Description
|
453
|
+
# of Function Failure Error in Apache Cassandra native protocol spec v4
|
454
|
+
class FunctionCallError < ::StandardError
|
455
|
+
include ExecutionError
|
456
|
+
|
457
|
+
# @return [String] keyspace
|
458
|
+
attr_reader :keyspace
|
459
|
+
# @return [String] name
|
460
|
+
attr_reader :name
|
461
|
+
# @return [String] signature
|
462
|
+
attr_reader :signature
|
463
|
+
|
464
|
+
# @private
|
465
|
+
def initialize(message,
|
466
|
+
payload,
|
467
|
+
warnings,
|
468
|
+
r_keyspace,
|
469
|
+
statement,
|
470
|
+
options,
|
471
|
+
hosts,
|
472
|
+
consistency,
|
473
|
+
retries,
|
474
|
+
keyspace,
|
475
|
+
name,
|
476
|
+
signature)
|
477
|
+
super(message,
|
478
|
+
payload,
|
479
|
+
warnings,
|
480
|
+
r_keyspace,
|
481
|
+
statement,
|
482
|
+
options,
|
483
|
+
hosts,
|
484
|
+
consistency,
|
485
|
+
retries)
|
486
|
+
@keyspace = keyspace
|
487
|
+
@name = name
|
488
|
+
@signature = signature
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
# Client error represents bad driver state or mis-configuration
|
493
|
+
class ClientError < ::StandardError
|
494
|
+
include Error
|
495
|
+
end
|
496
|
+
|
497
|
+
# Raised when some client message triggered a protocol violation (for
|
498
|
+
# instance a QUERY message is sent before a STARTUP one has been sent)
|
499
|
+
#
|
500
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L656-L658 Description
|
501
|
+
# of Protocol Error in Apache Cassandra native protocol spec v1
|
502
|
+
class ProtocolError < ClientError
|
503
|
+
# @private
|
504
|
+
def initialize(message,
|
505
|
+
payload,
|
506
|
+
warnings,
|
507
|
+
keyspace,
|
508
|
+
statement,
|
509
|
+
options,
|
510
|
+
hosts,
|
511
|
+
consistency,
|
512
|
+
retries)
|
513
|
+
super(message)
|
514
|
+
@payload = payload
|
515
|
+
@warnings = warnings
|
516
|
+
@keyspace = keyspace
|
517
|
+
@statement = statement
|
518
|
+
@options = options
|
519
|
+
@hosts = hosts
|
520
|
+
@consistency = consistency
|
521
|
+
@retries = retries
|
522
|
+
end
|
523
|
+
|
524
|
+
# Query execution information, such as number of retries and all tried hosts, etc.
|
525
|
+
# @return [Cassandra::Execution::Info]
|
526
|
+
def execution_info
|
527
|
+
@info ||= Execution::Info.new(@payload,
|
528
|
+
@warnings,
|
529
|
+
@keyspace,
|
530
|
+
@statement,
|
531
|
+
@options,
|
532
|
+
@hosts,
|
533
|
+
@consistency,
|
534
|
+
@retries,
|
535
|
+
nil)
|
536
|
+
end
|
537
|
+
end
|
538
|
+
|
539
|
+
# Raised when cannot authenticate to Cassandra
|
540
|
+
#
|
541
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L659-L660 Description
|
542
|
+
# of Bad Credentials Error in Apache Cassandra native protocol spec v1
|
543
|
+
class AuthenticationError < ClientError
|
544
|
+
# @private
|
545
|
+
def initialize(message,
|
546
|
+
payload,
|
547
|
+
warnings,
|
548
|
+
keyspace,
|
549
|
+
statement,
|
550
|
+
options,
|
551
|
+
hosts,
|
552
|
+
consistency,
|
553
|
+
retries)
|
554
|
+
super(message)
|
555
|
+
@payload = payload
|
556
|
+
@warnings = warnings
|
557
|
+
@keyspace = keyspace
|
558
|
+
@statement = statement
|
559
|
+
@options = options
|
560
|
+
@hosts = hosts
|
561
|
+
@consistency = consistency
|
562
|
+
@retries = retries
|
563
|
+
end
|
564
|
+
|
565
|
+
# Query execution information, such as number of retries and all tried hosts, etc.
|
566
|
+
# @return [Cassandra::Execution::Info]
|
567
|
+
def execution_info
|
568
|
+
@info ||= Execution::Info.new(@payload,
|
569
|
+
@warnings,
|
570
|
+
@keyspace,
|
571
|
+
@statement,
|
572
|
+
@options,
|
573
|
+
@hosts,
|
574
|
+
@consistency,
|
575
|
+
@retries,
|
576
|
+
nil)
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
# Mixed into all request validation errors.
|
581
|
+
module ValidationError
|
582
|
+
include Error
|
583
|
+
|
584
|
+
# @private
|
585
|
+
def initialize(message,
|
586
|
+
payload,
|
587
|
+
warnings,
|
588
|
+
keyspace,
|
589
|
+
statement,
|
590
|
+
options,
|
591
|
+
hosts,
|
592
|
+
consistency,
|
593
|
+
retries)
|
594
|
+
super(message)
|
595
|
+
@payload = payload
|
596
|
+
@warnings = warnings
|
597
|
+
@keyspace = keyspace
|
598
|
+
@statement = statement
|
599
|
+
@options = options
|
600
|
+
@hosts = hosts
|
601
|
+
@consistency = consistency
|
602
|
+
@retries = retries
|
603
|
+
end
|
604
|
+
|
605
|
+
# Query execution information, such as number of retries and all tried hosts, etc.
|
606
|
+
# @return [Cassandra::Execution::Info]
|
607
|
+
def execution_info
|
608
|
+
@info ||= Execution::Info.new(@payload,
|
609
|
+
@warnings,
|
610
|
+
@keyspace,
|
611
|
+
@statement,
|
612
|
+
@options,
|
613
|
+
@hosts,
|
614
|
+
@consistency,
|
615
|
+
@retries,
|
616
|
+
nil)
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
# Raised when a prepared statement tries to be executed and the provided
|
621
|
+
# prepared statement ID is not known by this host
|
622
|
+
#
|
623
|
+
# @note Seeing this error can be considered a Ruby Driver bug as it should
|
624
|
+
# handle automatic re-preparing internally.
|
625
|
+
#
|
626
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L738-L741 Description
|
627
|
+
# of Unprepared Error in Apache Cassandra native protocol spec v1
|
628
|
+
class UnpreparedError < ::StandardError
|
629
|
+
include ValidationError
|
630
|
+
# @return [String] prepared statement id that triggered the error
|
631
|
+
attr_reader :id
|
632
|
+
|
633
|
+
# @private
|
634
|
+
def initialize(message,
|
635
|
+
payload,
|
636
|
+
warnings,
|
637
|
+
keyspace,
|
638
|
+
statement,
|
639
|
+
options,
|
640
|
+
hosts,
|
641
|
+
consistency,
|
642
|
+
retries,
|
643
|
+
id)
|
644
|
+
super(message,
|
645
|
+
payload,
|
646
|
+
warnings,
|
647
|
+
keyspace,
|
648
|
+
statement,
|
649
|
+
options,
|
650
|
+
hosts,
|
651
|
+
consistency,
|
652
|
+
retries)
|
653
|
+
@id = id
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|
657
|
+
# Raised when the submitted query has a syntax error.
|
658
|
+
#
|
659
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L723 Description of
|
660
|
+
# Syntax Error in Apache Cassandra native protocol spec v1
|
661
|
+
class SyntaxError < ::StandardError
|
662
|
+
include ValidationError
|
663
|
+
end
|
664
|
+
|
665
|
+
# Raised when the logged user doesn't have the right to perform the query.
|
666
|
+
#
|
667
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L724-L725 Description
|
668
|
+
# of Unauthorized Error in Apache Cassandra native protocol spec v1
|
669
|
+
class UnauthorizedError < ::StandardError
|
670
|
+
include ValidationError
|
671
|
+
end
|
672
|
+
|
673
|
+
# Raised when the query is syntactically correct but invalid.
|
674
|
+
#
|
675
|
+
# @example Creating a table without selecting a keyspace
|
676
|
+
# begin
|
677
|
+
# session.execute("CREATE TABLE users (user_id INT PRIMARY KEY)")
|
678
|
+
# rescue Cassandra::Errors::InvalidError
|
679
|
+
# end
|
680
|
+
#
|
681
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L726 Description
|
682
|
+
# of Invalid Error in Apache Cassandra native protocol spec v1
|
683
|
+
class InvalidError < ::StandardError
|
684
|
+
include ValidationError
|
685
|
+
end
|
686
|
+
|
687
|
+
# Raised when the query is invalid because of some configuration issue.
|
688
|
+
#
|
689
|
+
# @example Dropping non-existent keyspace
|
690
|
+
# begin
|
691
|
+
# client.execute("DROP KEYSPACE unknown_keyspace")
|
692
|
+
# rescue Cassandra::Errors::ConfigurationError
|
693
|
+
# end
|
694
|
+
#
|
695
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L727 Description of
|
696
|
+
# Config Error in Apache Cassandra native protocol spec v1
|
697
|
+
class ConfigurationError < ::StandardError
|
698
|
+
include ValidationError
|
699
|
+
end
|
700
|
+
|
701
|
+
# Raised when the query attempted to create a keyspace or a table that was
|
702
|
+
# already existing.
|
703
|
+
#
|
704
|
+
# @example Creating a table twice
|
705
|
+
# session.execute("USE my_keyspace")
|
706
|
+
# session.execute("CREATE TABLE users (user_id INT PRIMARY KEY)")
|
707
|
+
# begin
|
708
|
+
# session.execute("CREATE TABLE users (user_id INT PRIMARY KEY)")
|
709
|
+
# rescue Cassandra::Errors::AlreadyExistsError => e
|
710
|
+
# p ['already exists', e.keyspace, e.table]
|
711
|
+
# end
|
712
|
+
#
|
713
|
+
# @see https://github.com/apache/cassandra/blob/cassandra-2.0.16/doc/native_protocol_v1.spec#L728-L737 Description
|
714
|
+
# of Already Exists Error in Apache Cassandra native protocol spec v1
|
715
|
+
class AlreadyExistsError < ConfigurationError
|
716
|
+
# @return [String] keyspace
|
717
|
+
attr_reader :keyspace
|
718
|
+
|
719
|
+
# @return [String, nil] table or `nil`
|
720
|
+
attr_reader :table
|
721
|
+
|
722
|
+
# @private
|
723
|
+
def initialize(message,
|
724
|
+
payload,
|
725
|
+
warnings,
|
726
|
+
r_keyspace,
|
727
|
+
statement,
|
728
|
+
options,
|
729
|
+
hosts,
|
730
|
+
consistency,
|
731
|
+
retries,
|
732
|
+
keyspace,
|
733
|
+
table)
|
734
|
+
super(message,
|
735
|
+
payload,
|
736
|
+
warnings,
|
737
|
+
r_keyspace,
|
738
|
+
statement,
|
739
|
+
options,
|
740
|
+
hosts,
|
741
|
+
consistency,
|
742
|
+
retries)
|
743
|
+
@keyspace = keyspace
|
744
|
+
@table = table
|
745
|
+
end
|
746
|
+
end
|
747
|
+
|
748
|
+
# This error is thrown when all attempted hosts raised a
|
749
|
+
# {Cassandra::Errors::HostError} during connection or query execution.
|
750
|
+
#
|
751
|
+
# @see Cassandra::Cluster#connect
|
752
|
+
# @see Cassandra::Session#execute
|
753
|
+
class NoHostsAvailable < ::StandardError
|
754
|
+
include Error
|
755
|
+
|
756
|
+
# @return [Hash{Cassandra::Host => Cassandra::Errors::HostError}] a map
|
757
|
+
# of hosts to underlying exceptions
|
758
|
+
attr_reader :errors
|
759
|
+
|
760
|
+
# @private
|
761
|
+
def initialize(errors = nil)
|
762
|
+
if errors
|
763
|
+
first = true
|
764
|
+
message = 'All attempted hosts failed'
|
765
|
+
errors.each do |(host, error)|
|
766
|
+
if first
|
767
|
+
first = false
|
768
|
+
message << ': '
|
769
|
+
else
|
770
|
+
message << ', '
|
771
|
+
end
|
772
|
+
message << "#{host.ip} (#{error.class.name}: #{error.message})"
|
773
|
+
end
|
774
|
+
else
|
775
|
+
message = 'All hosts down'
|
776
|
+
end
|
777
|
+
|
778
|
+
super(message)
|
779
|
+
|
780
|
+
@errors = errors || {}
|
781
|
+
end
|
782
|
+
end
|
783
|
+
end
|
784
|
+
end
|