cassandra-driver 1.0.0.beta.2-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +4 -0
- data/README.md +125 -0
- data/lib/cassandra/auth/providers/password.rb +73 -0
- data/lib/cassandra/auth/providers.rb +16 -0
- data/lib/cassandra/auth.rb +97 -0
- data/lib/cassandra/client/batch.rb +212 -0
- data/lib/cassandra/client/client.rb +591 -0
- data/lib/cassandra/client/column_metadata.rb +54 -0
- data/lib/cassandra/client/connection_manager.rb +72 -0
- data/lib/cassandra/client/connector.rb +277 -0
- data/lib/cassandra/client/execute_options_decoder.rb +59 -0
- data/lib/cassandra/client/null_logger.rb +37 -0
- data/lib/cassandra/client/peer_discovery.rb +50 -0
- data/lib/cassandra/client/prepared_statement.rb +314 -0
- data/lib/cassandra/client/query_result.rb +230 -0
- data/lib/cassandra/client/request_runner.rb +71 -0
- data/lib/cassandra/client/result_metadata.rb +48 -0
- data/lib/cassandra/client/void_result.rb +78 -0
- data/lib/cassandra/client.rb +144 -0
- data/lib/cassandra/cluster/client.rb +768 -0
- data/lib/cassandra/cluster/connector.rb +244 -0
- data/lib/cassandra/cluster/control_connection.rb +425 -0
- data/lib/cassandra/cluster/metadata.rb +124 -0
- data/lib/cassandra/cluster/options.rb +42 -0
- data/lib/cassandra/cluster/registry.rb +198 -0
- data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +47 -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/partitioners.rb +21 -0
- data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +92 -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/cluster/schema/replication_strategies.rb +21 -0
- data/lib/cassandra/cluster/schema/type_parser.rb +138 -0
- data/lib/cassandra/cluster/schema.rb +340 -0
- data/lib/cassandra/cluster.rb +215 -0
- data/lib/cassandra/column.rb +92 -0
- data/lib/cassandra/compression/compressors/lz4.rb +72 -0
- data/lib/cassandra/compression/compressors/snappy.rb +66 -0
- data/lib/cassandra/compression.rb +66 -0
- data/lib/cassandra/driver.rb +111 -0
- data/lib/cassandra/errors.rb +79 -0
- data/lib/cassandra/execution/info.rb +51 -0
- data/lib/cassandra/execution/options.rb +80 -0
- data/lib/cassandra/execution/trace.rb +152 -0
- data/lib/cassandra/future.rb +675 -0
- data/lib/cassandra/host.rb +79 -0
- data/lib/cassandra/keyspace.rb +133 -0
- data/lib/cassandra/listener.rb +87 -0
- data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +149 -0
- data/lib/cassandra/load_balancing/policies/round_robin.rb +132 -0
- data/lib/cassandra/load_balancing/policies/token_aware.rb +119 -0
- data/lib/cassandra/load_balancing/policies/white_list.rb +90 -0
- data/lib/cassandra/load_balancing/policies.rb +19 -0
- data/lib/cassandra/load_balancing.rb +113 -0
- data/lib/cassandra/protocol/cql_byte_buffer.rb +307 -0
- data/lib/cassandra/protocol/cql_protocol_handler.rb +323 -0
- data/lib/cassandra/protocol/frame_decoder.rb +128 -0
- data/lib/cassandra/protocol/frame_encoder.rb +48 -0
- data/lib/cassandra/protocol/request.rb +38 -0
- data/lib/cassandra/protocol/requests/auth_response_request.rb +47 -0
- data/lib/cassandra/protocol/requests/batch_request.rb +76 -0
- data/lib/cassandra/protocol/requests/credentials_request.rb +47 -0
- data/lib/cassandra/protocol/requests/execute_request.rb +103 -0
- data/lib/cassandra/protocol/requests/options_request.rb +39 -0
- data/lib/cassandra/protocol/requests/prepare_request.rb +50 -0
- data/lib/cassandra/protocol/requests/query_request.rb +153 -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 +38 -0
- data/lib/cassandra/protocol/responses/auth_challenge_response.rb +41 -0
- data/lib/cassandra/protocol/responses/auth_success_response.rb +41 -0
- data/lib/cassandra/protocol/responses/authenticate_response.rb +41 -0
- data/lib/cassandra/protocol/responses/detailed_error_response.rb +60 -0
- data/lib/cassandra/protocol/responses/error_response.rb +50 -0
- data/lib/cassandra/protocol/responses/event_response.rb +39 -0
- data/lib/cassandra/protocol/responses/prepared_result_response.rb +64 -0
- data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +43 -0
- data/lib/cassandra/protocol/responses/ready_response.rb +44 -0
- data/lib/cassandra/protocol/responses/result_response.rb +48 -0
- data/lib/cassandra/protocol/responses/rows_result_response.rb +139 -0
- data/lib/cassandra/protocol/responses/schema_change_event_response.rb +60 -0
- data/lib/cassandra/protocol/responses/schema_change_result_response.rb +57 -0
- data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +42 -0
- data/lib/cassandra/protocol/responses/status_change_event_response.rb +44 -0
- data/lib/cassandra/protocol/responses/supported_response.rb +41 -0
- data/lib/cassandra/protocol/responses/topology_change_event_response.rb +34 -0
- data/lib/cassandra/protocol/responses/void_result_response.rb +39 -0
- data/lib/cassandra/protocol/type_converter.rb +384 -0
- data/lib/cassandra/protocol.rb +93 -0
- data/lib/cassandra/reconnection/policies/constant.rb +48 -0
- data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
- data/lib/cassandra/reconnection/policies.rb +20 -0
- data/lib/cassandra/reconnection.rb +49 -0
- data/lib/cassandra/result.rb +215 -0
- data/lib/cassandra/retry/policies/default.rb +47 -0
- data/lib/cassandra/retry/policies/downgrading_consistency.rb +71 -0
- data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
- data/lib/cassandra/retry/policies.rb +21 -0
- data/lib/cassandra/retry.rb +142 -0
- data/lib/cassandra/session.rb +202 -0
- data/lib/cassandra/statement.rb +22 -0
- data/lib/cassandra/statements/batch.rb +95 -0
- data/lib/cassandra/statements/bound.rb +48 -0
- data/lib/cassandra/statements/prepared.rb +81 -0
- data/lib/cassandra/statements/simple.rb +58 -0
- data/lib/cassandra/statements/void.rb +33 -0
- data/lib/cassandra/statements.rb +23 -0
- data/lib/cassandra/table.rb +299 -0
- data/lib/cassandra/time_uuid.rb +142 -0
- data/lib/cassandra/util.rb +167 -0
- data/lib/cassandra/uuid.rb +104 -0
- data/lib/cassandra/version.rb +21 -0
- data/lib/cassandra.rb +428 -0
- data/lib/cassandra_murmur3.jar +0 -0
- metadata +211 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 2013-2014 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
|
+
VERSION = '1.0.0.beta.2'.freeze
|
|
21
|
+
end
|
data/lib/cassandra.rb
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
#--
|
|
4
|
+
# Copyright 2013-2014 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
|
+
|
|
20
|
+
require 'ione'
|
|
21
|
+
require 'json'
|
|
22
|
+
|
|
23
|
+
require 'monitor'
|
|
24
|
+
require 'ipaddr'
|
|
25
|
+
require 'set'
|
|
26
|
+
require 'bigdecimal'
|
|
27
|
+
require 'forwardable'
|
|
28
|
+
require 'timeout'
|
|
29
|
+
require 'digest'
|
|
30
|
+
require 'stringio'
|
|
31
|
+
require 'resolv'
|
|
32
|
+
require 'openssl'
|
|
33
|
+
|
|
34
|
+
module Cassandra
|
|
35
|
+
# A list of all supported request consistencies
|
|
36
|
+
# @see Cassandra::Session#execute_async
|
|
37
|
+
CONSISTENCIES = [ :any, :one, :two, :three, :quorum, :all, :local_quorum,
|
|
38
|
+
:each_quorum, :serial, :local_serial, :local_one ].freeze
|
|
39
|
+
|
|
40
|
+
# A list of all supported serial consistencies
|
|
41
|
+
# @see Cassandra::Session#execute_async
|
|
42
|
+
SERIAL_CONSISTENCIES = [:serial, :local_serial].freeze
|
|
43
|
+
|
|
44
|
+
# Creates a {Cassandra::Cluster} instance
|
|
45
|
+
#
|
|
46
|
+
# @option options [Array<String, IPAddr>] :hosts (['127.0.0.1']) a list of
|
|
47
|
+
# initial addresses. Note that the entire list of cluster members will be
|
|
48
|
+
# discovered automatically once a connection to any hosts from the original
|
|
49
|
+
# list is successful.
|
|
50
|
+
#
|
|
51
|
+
# @option options [Integer] :port (9042) cassandra native protocol port.
|
|
52
|
+
#
|
|
53
|
+
# @option options [Numeric] :connect_timeout (10) connection timeout in
|
|
54
|
+
# seconds.
|
|
55
|
+
#
|
|
56
|
+
# @option options [String] :username (none) username to use for
|
|
57
|
+
# authentication to cassandra. Note that you must also specify `:password`.
|
|
58
|
+
#
|
|
59
|
+
# @option options [String] :password (none) password to use for
|
|
60
|
+
# authentication to cassandra. Note that you must also specify `:username`.
|
|
61
|
+
#
|
|
62
|
+
# @option options [Boolean, OpenSSL::SSL::SSLContext] :ssl (false) enable
|
|
63
|
+
# default ssl authentication if `true` (not recommended). Also accepts an
|
|
64
|
+
# initialized {OpenSSL::SSL::SSLContext}. Note that this option should be
|
|
65
|
+
# ignored if `:server_cert`, `:client_cert`, `:private_key` or
|
|
66
|
+
# `:passphrase` are given.
|
|
67
|
+
#
|
|
68
|
+
# @option options [String] :server_cert (none) path to server certificate or
|
|
69
|
+
# certificate authority file.
|
|
70
|
+
#
|
|
71
|
+
# @option options [String] :client_cert (none) path to client certificate
|
|
72
|
+
# file. Note that this option is only required when encryption is
|
|
73
|
+
# configured to require client authentication.
|
|
74
|
+
#
|
|
75
|
+
# @option options [String] :private_key (none) path to client private key.
|
|
76
|
+
# Note that this option is only required when encryption is configured to
|
|
77
|
+
# require client authentication.
|
|
78
|
+
#
|
|
79
|
+
# @option options [String] :passphrase (none) passphrase for private key.
|
|
80
|
+
#
|
|
81
|
+
# @option options [Symbol] :compression (none) compression to use. Must be
|
|
82
|
+
# either `:snappy` or `:lz4`. Also note, that in order for compression to
|
|
83
|
+
# work, you must install 'snappy' or 'lz4-ruby' gems.
|
|
84
|
+
#
|
|
85
|
+
# @option options [Cassandra::LoadBalancing::Policy] :load_balancing_policy
|
|
86
|
+
# default: {Cassandra::LoadBalancing::Policies::RoundRobin}.
|
|
87
|
+
#
|
|
88
|
+
# @option options [Cassandra::Reconnection::Policy] :reconnection_policy
|
|
89
|
+
# default: {Cassandra::Reconnection::Policies::Exponential}. Note that the
|
|
90
|
+
# default policy is configured with
|
|
91
|
+
# `Reconnection::Policies::Exponential.new(0.5, 30, 2)`.
|
|
92
|
+
#
|
|
93
|
+
# @option options [Cassandra::Retry::Policy] :retry_policy default:
|
|
94
|
+
# {Cassandra::Retry::Policies::Default}.
|
|
95
|
+
#
|
|
96
|
+
# @option options [Logger] :logger (none) logger. a {Logger} instance from the
|
|
97
|
+
# standard library or any object responding to standard log methods
|
|
98
|
+
# (`#debug`, `#info`, `#warn`, `#error` and `#fatal`).
|
|
99
|
+
#
|
|
100
|
+
# @option options [Enumerable<Cassandra::Listener>] :listeners (none)
|
|
101
|
+
# initial listeners. A list of initial cluster state listeners. Note that a
|
|
102
|
+
# `:load_balancing` policy is automatically registered with the cluster.
|
|
103
|
+
#
|
|
104
|
+
# @option options [Symbol] :consistency (:quorum) default consistency to use
|
|
105
|
+
# for all requests. Must be one of {Cassandra::CONSISTENCIES}.
|
|
106
|
+
#
|
|
107
|
+
# @option options [Boolean] :trace (false) whether or not to trace all
|
|
108
|
+
# requests by default.
|
|
109
|
+
#
|
|
110
|
+
# @option options [Integer] :page_size (nil) default page size for all select
|
|
111
|
+
# queries.
|
|
112
|
+
#
|
|
113
|
+
# @option options [Hash{String => String}] :credentials (none) a hash of credentials - to be used with [credentials authentication in cassandra 1.2](https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v1.spec#L238-L250). Note that if you specified `:username` and `:password` options, those credentials are configured automatically.
|
|
114
|
+
#
|
|
115
|
+
# @option options [Cassandra::Auth::Provider] :auth_provider (none) a custom auth provider to be used with [SASL authentication in cassandra 2.0](https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v2.spec#L257-L273). Note that if you have specified `:username` and `:password`, then a {Cassandra::Auth::Providers::Password} will be used automatically.
|
|
116
|
+
#
|
|
117
|
+
# @option options [Cassandra::Compressor] :compressor (none) a custom
|
|
118
|
+
# compressor. Note that if you have specified `:compression`, an
|
|
119
|
+
# appropriate compressor will be provided automatically.
|
|
120
|
+
#
|
|
121
|
+
# @option options [Object<#all, #error, #value, #promise>] :futures_factory
|
|
122
|
+
# (none) a custom futures factory to assist with integration into existing
|
|
123
|
+
# futures library. Note that promises returned by this object must conform
|
|
124
|
+
# to {Cassandra::Promise} api, which is not yet public. Things may change,
|
|
125
|
+
# use at your own risk.
|
|
126
|
+
#
|
|
127
|
+
# @example Connecting to localhost
|
|
128
|
+
# cluster = Cassandra.connect
|
|
129
|
+
#
|
|
130
|
+
# @example Configuring {Cassandra::Cluster}
|
|
131
|
+
# cluster = Cassandra.connect(
|
|
132
|
+
# username: username,
|
|
133
|
+
# password: password,
|
|
134
|
+
# hosts: ['10.0.1.1', '10.0.1.2', '10.0.1.3']
|
|
135
|
+
# )
|
|
136
|
+
#
|
|
137
|
+
# @return [Cassandra::Cluster] a cluster instance
|
|
138
|
+
def self.connect(options = {})
|
|
139
|
+
options.select! do |key, value|
|
|
140
|
+
[ :credentials, :auth_provider, :compression, :hosts, :logger, :port,
|
|
141
|
+
:load_balancing_policy, :reconnection_policy, :retry_policy, :listeners,
|
|
142
|
+
:consistency, :trace, :page_size, :compressor, :username, :password,
|
|
143
|
+
:ssl, :server_cert, :client_cert, :private_key, :passphrase,
|
|
144
|
+
:connect_timeout, :futures_factory
|
|
145
|
+
].include?(key)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
has_username = options.has_key?(:username)
|
|
149
|
+
has_password = options.has_key?(:password)
|
|
150
|
+
if has_username || has_password
|
|
151
|
+
if has_username && !has_password
|
|
152
|
+
raise ::ArgumentError, "both :username and :password options must be specified, but only :username given"
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
if !has_username && has_password
|
|
156
|
+
raise ::ArgumentError, "both :username and :password options must be specified, but only :password given"
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
username = String(options.delete(:username))
|
|
160
|
+
password = String(options.delete(:password))
|
|
161
|
+
|
|
162
|
+
raise ::ArgumentError, ":username cannot be empty" if username.empty?
|
|
163
|
+
raise ::ArgumentError, ":password cannot be empty" if password.empty?
|
|
164
|
+
|
|
165
|
+
options[:credentials] = {:username => username, :password => password}
|
|
166
|
+
options[:auth_provider] = Auth::Providers::Password.new(username, password)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if options.has_key?(:credentials)
|
|
170
|
+
credentials = options[:credentials]
|
|
171
|
+
|
|
172
|
+
unless credentials.is_a?(Hash)
|
|
173
|
+
raise ::ArgumentError, ":credentials must be a hash, #{credentials.inspect} given"
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if options.has_key?(:auth_provider)
|
|
178
|
+
auth_provider = options[:auth_provider]
|
|
179
|
+
|
|
180
|
+
unless auth_provider.respond_to?(:create_authenticator)
|
|
181
|
+
raise ::ArgumentError, ":auth_provider #{auth_provider.inspect} must respond to :create_authenticator, but doesn't"
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
has_client_cert = options.has_key?(:client_cert)
|
|
186
|
+
has_private_key = options.has_key?(:private_key)
|
|
187
|
+
|
|
188
|
+
if has_client_cert || has_private_key
|
|
189
|
+
if has_client_cert && !has_private_key
|
|
190
|
+
raise ::ArgumentError, "both :client_cert and :private_key options must be specified, but only :client_cert given"
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
if !has_client_cert && has_private_key
|
|
194
|
+
raise ::ArgumentError, "both :client_cert and :private_key options must be specified, but only :private_key given"
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
client_cert = ::File.expand_path(options[:client_cert])
|
|
198
|
+
private_key = ::File.expand_path(options[:private_key])
|
|
199
|
+
|
|
200
|
+
unless ::File.exists?(client_cert)
|
|
201
|
+
raise ::ArgumentError, ":client_cert #{client_cert.inspect} doesn't exist"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
unless ::File.exists?(private_key)
|
|
205
|
+
raise ::ArgumentError, ":private_key #{private_key.inspect} doesn't exist"
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
has_server_cert = options.has_key?(:server_cert)
|
|
210
|
+
|
|
211
|
+
if has_server_cert
|
|
212
|
+
server_cert = ::File.expand_path(options[:server_cert])
|
|
213
|
+
|
|
214
|
+
unless ::File.exists?(server_cert)
|
|
215
|
+
raise ::ArgumentError, ":server_cert #{server_cert.inspect} doesn't exist"
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
if has_client_cert || has_server_cert
|
|
220
|
+
context = ::OpenSSL::SSL::SSLContext.new
|
|
221
|
+
|
|
222
|
+
if has_server_cert
|
|
223
|
+
context.ca_file = server_cert
|
|
224
|
+
context.verify_mode = ::OpenSSL::SSL::VERIFY_PEER
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
if has_client_cert
|
|
228
|
+
context.cert = ::OpenSSL::X509::Certificate.new(File.read(client_cert))
|
|
229
|
+
|
|
230
|
+
if options.has_key?(:passphrase)
|
|
231
|
+
context.key = ::OpenSSL::PKey::RSA.new(File.read(private_key), options[:passphrase])
|
|
232
|
+
else
|
|
233
|
+
context.key = ::OpenSSL::PKey::RSA.new(File.read(private_key))
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
options[:ssl] = context
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
if options.has_key?(:ssl)
|
|
241
|
+
ssl = options[:ssl]
|
|
242
|
+
|
|
243
|
+
unless ssl.is_a?(::TrueClass) || ssl.is_a?(::FalseClass) || ssl.is_a?(::OpenSSL::SSL::SSLContext)
|
|
244
|
+
raise ":ssl must be a boolean or an OpenSSL::SSL::SSLContext, #{ssl.inspect} given"
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
if options.has_key?(:compression)
|
|
249
|
+
compression = options.delete(:compression)
|
|
250
|
+
|
|
251
|
+
case compression
|
|
252
|
+
when :snappy
|
|
253
|
+
require 'cassandra/compression/compressors/snappy'
|
|
254
|
+
options[:compressor] = Compression::Compressors::Snappy.new
|
|
255
|
+
when :lz4
|
|
256
|
+
require 'cassandra/compression/compressors/lz4'
|
|
257
|
+
options[:compressor] = Compression::Compressors::Lz4.new
|
|
258
|
+
else
|
|
259
|
+
raise ::ArgumentError, ":compression must be either :snappy or :lz4, #{compression.inspect} given"
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
if options.has_key?(:compressor)
|
|
264
|
+
compressor = options[:compressor]
|
|
265
|
+
methods = [:algorithm, :compress?, :compress, :decompress]
|
|
266
|
+
|
|
267
|
+
unless methods.all? {|method| compressor.respond_to?(method)}
|
|
268
|
+
raise ::ArgumentError, ":compressor #{compressor.inspect} must respond to #{methods.inspect}, but doesn't"
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
if options.has_key?(:logger)
|
|
273
|
+
logger = options[:logger]
|
|
274
|
+
methods = [:debug, :info, :warn, :error, :fatal]
|
|
275
|
+
|
|
276
|
+
unless methods.all? {|method| logger.respond_to?(method)}
|
|
277
|
+
raise ::ArgumentError, ":logger #{logger.inspect} must respond to #{methods.inspect}, but doesn't"
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
if options.has_key?(:port)
|
|
282
|
+
port = options[:port] = Integer(options[:port])
|
|
283
|
+
|
|
284
|
+
if port < 0 || port > 65536
|
|
285
|
+
raise ::ArgumentError, ":port must be a valid ip port, #{port.given}"
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
if options.has_key?(:connect_timeout)
|
|
290
|
+
timeout = options[:connect_timeout] = Integer(options[:connect_timeout])
|
|
291
|
+
|
|
292
|
+
if timeout < 0
|
|
293
|
+
raise ::ArgumentError, ":connect_timeout must be a positive value, #{timeout.given}"
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
if options.has_key?(:load_balancing_policy)
|
|
298
|
+
load_balancing_policy = options[:load_balancing_policy]
|
|
299
|
+
methods = [:host_up, :host_down, :host_found, :host_lost, :setup, :distance, :plan]
|
|
300
|
+
|
|
301
|
+
unless methods.all? {|method| load_balancing_policy.respond_to?(method)}
|
|
302
|
+
raise ::ArgumentError, ":load_balancing_policy #{load_balancing_policy.inspect} must respond to #{methods.inspect}, but doesn't"
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
if options.has_key?(:reconnection_policy)
|
|
307
|
+
reconnection_policy = options[:reconnection_policy]
|
|
308
|
+
|
|
309
|
+
unless reconnection_policy.respond_to?(:schedule)
|
|
310
|
+
raise ::ArgumentError, ":reconnection_policy #{reconnection_policy.inspect} must respond to :schedule, but doesn't"
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
if options.has_key?(:retry_policy)
|
|
315
|
+
retry_policy = options[:retry_policy]
|
|
316
|
+
methods = [:read_timeout, :write_timeout, :unavailable]
|
|
317
|
+
|
|
318
|
+
unless methods.all? {|method| retry_policy.respond_to?(method)}
|
|
319
|
+
raise ::ArgumentError, ":retry_policy #{retry_policy.inspect} must respond to #{methods.inspect}, but doesn't"
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
if options.has_key?(:listeners)
|
|
324
|
+
listeners = options[:listeners]
|
|
325
|
+
|
|
326
|
+
unless listeners.respond_to?(:each)
|
|
327
|
+
raise ::ArgumentError, ":listeners must be an Enumerable, #{listeners.inspect} given"
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
if options.has_key?(:consistency)
|
|
332
|
+
consistency = options[:consistency]
|
|
333
|
+
|
|
334
|
+
unless CONSISTENCIES.include?(consistency)
|
|
335
|
+
raise ::ArgumentError, ":consistency must be one of #{CONSISTENCIES.inspect}, #{consistency.inspect} given"
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
if options.has_key?(:trace)
|
|
340
|
+
options[:trace] = !!options[:trace]
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
if options.has_key?(:page_size)
|
|
344
|
+
page_size = options[:page_size] = Integer(options[:page_size])
|
|
345
|
+
|
|
346
|
+
if page_size <= 0
|
|
347
|
+
raise ::ArgumentError, ":page_size must be a positive integer, #{page_size.inspect} given"
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
if options.has_key?(:futures_factory)
|
|
352
|
+
futures_factory = options[:futures_factory]
|
|
353
|
+
methods = [:error, :value, :promise, :all]
|
|
354
|
+
|
|
355
|
+
unless methods.all? {|method| futures_factory.respond_to?(method)}
|
|
356
|
+
raise ::ArgumentError, ":futures_factory #{futures_factory.inspect} must respond to #{methods.inspect}, but doesn't"
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
hosts = []
|
|
361
|
+
|
|
362
|
+
Array(options.fetch(:hosts, '127.0.0.1')).each do |host|
|
|
363
|
+
case host
|
|
364
|
+
when ::IPAddr
|
|
365
|
+
hosts << host
|
|
366
|
+
when ::String # ip address or hostname
|
|
367
|
+
Resolv.each_address(host) do |ip|
|
|
368
|
+
hosts << ::IPAddr.new(ip)
|
|
369
|
+
end
|
|
370
|
+
else
|
|
371
|
+
raise ::ArgumentError, ":hosts must be String or IPAddr, #{host.inspect} given"
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
if hosts.empty?
|
|
376
|
+
raise ::ArgumentError, ":hosts #{options[:hosts].inspect} could not be resolved to any ip address"
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
Driver.new(options).connect(hosts).value
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
require 'cassandra/errors'
|
|
384
|
+
require 'cassandra/uuid'
|
|
385
|
+
require 'cassandra/time_uuid'
|
|
386
|
+
require 'cassandra/compression'
|
|
387
|
+
require 'cassandra/protocol'
|
|
388
|
+
require 'cassandra/auth'
|
|
389
|
+
require 'cassandra/client'
|
|
390
|
+
|
|
391
|
+
require 'cassandra/future'
|
|
392
|
+
require 'cassandra/cluster'
|
|
393
|
+
require 'cassandra/driver'
|
|
394
|
+
require 'cassandra/host'
|
|
395
|
+
require 'cassandra/session'
|
|
396
|
+
require 'cassandra/result'
|
|
397
|
+
require 'cassandra/statement'
|
|
398
|
+
require 'cassandra/statements'
|
|
399
|
+
|
|
400
|
+
require 'cassandra/column'
|
|
401
|
+
require 'cassandra/table'
|
|
402
|
+
require 'cassandra/keyspace'
|
|
403
|
+
|
|
404
|
+
require 'cassandra/execution/info'
|
|
405
|
+
require 'cassandra/execution/options'
|
|
406
|
+
require 'cassandra/execution/trace'
|
|
407
|
+
|
|
408
|
+
require 'cassandra/load_balancing'
|
|
409
|
+
require 'cassandra/reconnection'
|
|
410
|
+
require 'cassandra/retry'
|
|
411
|
+
|
|
412
|
+
require 'cassandra/util'
|
|
413
|
+
|
|
414
|
+
# murmur3 hash extension
|
|
415
|
+
require 'cassandra_murmur3'
|
|
416
|
+
|
|
417
|
+
module Cassandra
|
|
418
|
+
# @private
|
|
419
|
+
Io = Ione::Io
|
|
420
|
+
# @private
|
|
421
|
+
VOID_STATEMENT = Statements::Void.new
|
|
422
|
+
# @private
|
|
423
|
+
VOID_OPTIONS = Execution::Options.new({:consistency => :one})
|
|
424
|
+
# @private
|
|
425
|
+
NO_HOSTS = Errors::NoHostsAvailable.new
|
|
426
|
+
# @private
|
|
427
|
+
EMPTY_LIST = [].freeze
|
|
428
|
+
end
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cassandra-driver
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0.beta.2
|
|
5
|
+
platform: java
|
|
6
|
+
authors:
|
|
7
|
+
- Theo Hultberg
|
|
8
|
+
- Bulat Shakirzyanov
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: ione
|
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ~>
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: 1.2.0.pre4
|
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ~>
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 1.2.0.pre4
|
|
26
|
+
prerelease: false
|
|
27
|
+
type: :runtime
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: bundler
|
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ~>
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '1.6'
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ~>
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.6'
|
|
40
|
+
prerelease: false
|
|
41
|
+
type: :development
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: rake
|
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ~>
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '10.0'
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '10.0'
|
|
54
|
+
prerelease: false
|
|
55
|
+
type: :development
|
|
56
|
+
description: A pure Ruby driver for Apache Cassandra
|
|
57
|
+
email:
|
|
58
|
+
- theo@iconara.net
|
|
59
|
+
- bulat.shakirzyanov@datastax.com
|
|
60
|
+
executables: []
|
|
61
|
+
extensions: []
|
|
62
|
+
extra_rdoc_files:
|
|
63
|
+
- README.md
|
|
64
|
+
files:
|
|
65
|
+
- lib/cassandra.rb
|
|
66
|
+
- lib/cassandra/auth.rb
|
|
67
|
+
- lib/cassandra/client.rb
|
|
68
|
+
- lib/cassandra/cluster.rb
|
|
69
|
+
- lib/cassandra/column.rb
|
|
70
|
+
- lib/cassandra/compression.rb
|
|
71
|
+
- lib/cassandra/driver.rb
|
|
72
|
+
- lib/cassandra/errors.rb
|
|
73
|
+
- lib/cassandra/future.rb
|
|
74
|
+
- lib/cassandra/host.rb
|
|
75
|
+
- lib/cassandra/keyspace.rb
|
|
76
|
+
- lib/cassandra/listener.rb
|
|
77
|
+
- lib/cassandra/load_balancing.rb
|
|
78
|
+
- lib/cassandra/protocol.rb
|
|
79
|
+
- lib/cassandra/reconnection.rb
|
|
80
|
+
- lib/cassandra/result.rb
|
|
81
|
+
- lib/cassandra/retry.rb
|
|
82
|
+
- lib/cassandra/session.rb
|
|
83
|
+
- lib/cassandra/statement.rb
|
|
84
|
+
- lib/cassandra/statements.rb
|
|
85
|
+
- lib/cassandra/table.rb
|
|
86
|
+
- lib/cassandra/time_uuid.rb
|
|
87
|
+
- lib/cassandra/util.rb
|
|
88
|
+
- lib/cassandra/uuid.rb
|
|
89
|
+
- lib/cassandra/version.rb
|
|
90
|
+
- lib/cassandra/auth/providers.rb
|
|
91
|
+
- lib/cassandra/auth/providers/password.rb
|
|
92
|
+
- lib/cassandra/client/batch.rb
|
|
93
|
+
- lib/cassandra/client/client.rb
|
|
94
|
+
- lib/cassandra/client/column_metadata.rb
|
|
95
|
+
- lib/cassandra/client/connection_manager.rb
|
|
96
|
+
- lib/cassandra/client/connector.rb
|
|
97
|
+
- lib/cassandra/client/execute_options_decoder.rb
|
|
98
|
+
- lib/cassandra/client/null_logger.rb
|
|
99
|
+
- lib/cassandra/client/peer_discovery.rb
|
|
100
|
+
- lib/cassandra/client/prepared_statement.rb
|
|
101
|
+
- lib/cassandra/client/query_result.rb
|
|
102
|
+
- lib/cassandra/client/request_runner.rb
|
|
103
|
+
- lib/cassandra/client/result_metadata.rb
|
|
104
|
+
- lib/cassandra/client/void_result.rb
|
|
105
|
+
- lib/cassandra/cluster/client.rb
|
|
106
|
+
- lib/cassandra/cluster/connector.rb
|
|
107
|
+
- lib/cassandra/cluster/control_connection.rb
|
|
108
|
+
- lib/cassandra/cluster/metadata.rb
|
|
109
|
+
- lib/cassandra/cluster/options.rb
|
|
110
|
+
- lib/cassandra/cluster/registry.rb
|
|
111
|
+
- lib/cassandra/cluster/schema.rb
|
|
112
|
+
- lib/cassandra/cluster/schema/partitioners.rb
|
|
113
|
+
- lib/cassandra/cluster/schema/replication_strategies.rb
|
|
114
|
+
- lib/cassandra/cluster/schema/type_parser.rb
|
|
115
|
+
- lib/cassandra/cluster/schema/partitioners/murmur3.rb
|
|
116
|
+
- lib/cassandra/cluster/schema/partitioners/ordered.rb
|
|
117
|
+
- lib/cassandra/cluster/schema/partitioners/random.rb
|
|
118
|
+
- lib/cassandra/cluster/schema/replication_strategies/network_topology.rb
|
|
119
|
+
- lib/cassandra/cluster/schema/replication_strategies/none.rb
|
|
120
|
+
- lib/cassandra/cluster/schema/replication_strategies/simple.rb
|
|
121
|
+
- lib/cassandra/compression/compressors/lz4.rb
|
|
122
|
+
- lib/cassandra/compression/compressors/snappy.rb
|
|
123
|
+
- lib/cassandra/execution/info.rb
|
|
124
|
+
- lib/cassandra/execution/options.rb
|
|
125
|
+
- lib/cassandra/execution/trace.rb
|
|
126
|
+
- lib/cassandra/load_balancing/policies.rb
|
|
127
|
+
- lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb
|
|
128
|
+
- lib/cassandra/load_balancing/policies/round_robin.rb
|
|
129
|
+
- lib/cassandra/load_balancing/policies/token_aware.rb
|
|
130
|
+
- lib/cassandra/load_balancing/policies/white_list.rb
|
|
131
|
+
- lib/cassandra/protocol/cql_byte_buffer.rb
|
|
132
|
+
- lib/cassandra/protocol/cql_protocol_handler.rb
|
|
133
|
+
- lib/cassandra/protocol/frame_decoder.rb
|
|
134
|
+
- lib/cassandra/protocol/frame_encoder.rb
|
|
135
|
+
- lib/cassandra/protocol/request.rb
|
|
136
|
+
- lib/cassandra/protocol/response.rb
|
|
137
|
+
- lib/cassandra/protocol/type_converter.rb
|
|
138
|
+
- lib/cassandra/protocol/requests/auth_response_request.rb
|
|
139
|
+
- lib/cassandra/protocol/requests/batch_request.rb
|
|
140
|
+
- lib/cassandra/protocol/requests/credentials_request.rb
|
|
141
|
+
- lib/cassandra/protocol/requests/execute_request.rb
|
|
142
|
+
- lib/cassandra/protocol/requests/options_request.rb
|
|
143
|
+
- lib/cassandra/protocol/requests/prepare_request.rb
|
|
144
|
+
- lib/cassandra/protocol/requests/query_request.rb
|
|
145
|
+
- lib/cassandra/protocol/requests/register_request.rb
|
|
146
|
+
- lib/cassandra/protocol/requests/startup_request.rb
|
|
147
|
+
- lib/cassandra/protocol/requests/void_query_request.rb
|
|
148
|
+
- lib/cassandra/protocol/responses/auth_challenge_response.rb
|
|
149
|
+
- lib/cassandra/protocol/responses/auth_success_response.rb
|
|
150
|
+
- lib/cassandra/protocol/responses/authenticate_response.rb
|
|
151
|
+
- lib/cassandra/protocol/responses/detailed_error_response.rb
|
|
152
|
+
- lib/cassandra/protocol/responses/error_response.rb
|
|
153
|
+
- lib/cassandra/protocol/responses/event_response.rb
|
|
154
|
+
- lib/cassandra/protocol/responses/prepared_result_response.rb
|
|
155
|
+
- lib/cassandra/protocol/responses/raw_rows_result_response.rb
|
|
156
|
+
- lib/cassandra/protocol/responses/ready_response.rb
|
|
157
|
+
- lib/cassandra/protocol/responses/result_response.rb
|
|
158
|
+
- lib/cassandra/protocol/responses/rows_result_response.rb
|
|
159
|
+
- lib/cassandra/protocol/responses/schema_change_event_response.rb
|
|
160
|
+
- lib/cassandra/protocol/responses/schema_change_result_response.rb
|
|
161
|
+
- lib/cassandra/protocol/responses/set_keyspace_result_response.rb
|
|
162
|
+
- lib/cassandra/protocol/responses/status_change_event_response.rb
|
|
163
|
+
- lib/cassandra/protocol/responses/supported_response.rb
|
|
164
|
+
- lib/cassandra/protocol/responses/topology_change_event_response.rb
|
|
165
|
+
- lib/cassandra/protocol/responses/void_result_response.rb
|
|
166
|
+
- lib/cassandra/reconnection/policies.rb
|
|
167
|
+
- lib/cassandra/reconnection/policies/constant.rb
|
|
168
|
+
- lib/cassandra/reconnection/policies/exponential.rb
|
|
169
|
+
- lib/cassandra/retry/policies.rb
|
|
170
|
+
- lib/cassandra/retry/policies/default.rb
|
|
171
|
+
- lib/cassandra/retry/policies/downgrading_consistency.rb
|
|
172
|
+
- lib/cassandra/retry/policies/fallthrough.rb
|
|
173
|
+
- lib/cassandra/statements/batch.rb
|
|
174
|
+
- lib/cassandra/statements/bound.rb
|
|
175
|
+
- lib/cassandra/statements/prepared.rb
|
|
176
|
+
- lib/cassandra/statements/simple.rb
|
|
177
|
+
- lib/cassandra/statements/void.rb
|
|
178
|
+
- README.md
|
|
179
|
+
- .yardopts
|
|
180
|
+
- lib/cassandra_murmur3.jar
|
|
181
|
+
homepage: http://datastax.github.io/ruby-driver
|
|
182
|
+
licenses:
|
|
183
|
+
- Apache License 2.0
|
|
184
|
+
metadata: {}
|
|
185
|
+
post_install_message:
|
|
186
|
+
rdoc_options:
|
|
187
|
+
- --title
|
|
188
|
+
- Datastax Ruby Driver
|
|
189
|
+
- --main
|
|
190
|
+
- README.md
|
|
191
|
+
- --line-numbers
|
|
192
|
+
require_paths:
|
|
193
|
+
- lib
|
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
|
+
requirements:
|
|
196
|
+
- - '>='
|
|
197
|
+
- !ruby/object:Gem::Version
|
|
198
|
+
version: 1.9.3
|
|
199
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
|
+
requirements:
|
|
201
|
+
- - '>'
|
|
202
|
+
- !ruby/object:Gem::Version
|
|
203
|
+
version: 1.3.1
|
|
204
|
+
requirements: []
|
|
205
|
+
rubyforge_project:
|
|
206
|
+
rubygems_version: 2.1.9
|
|
207
|
+
signing_key:
|
|
208
|
+
specification_version: 4
|
|
209
|
+
summary: Datastax Ruby Driver for Apache Cassandra
|
|
210
|
+
test_files: []
|
|
211
|
+
has_rdoc:
|