cassandra-driver 1.0.0.beta.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +4 -0
  3. data/README.md +125 -0
  4. data/lib/cassandra/auth/providers/password.rb +73 -0
  5. data/lib/cassandra/auth/providers.rb +16 -0
  6. data/lib/cassandra/auth.rb +97 -0
  7. data/lib/cassandra/client/batch.rb +212 -0
  8. data/lib/cassandra/client/client.rb +591 -0
  9. data/lib/cassandra/client/column_metadata.rb +54 -0
  10. data/lib/cassandra/client/connection_manager.rb +72 -0
  11. data/lib/cassandra/client/connector.rb +277 -0
  12. data/lib/cassandra/client/execute_options_decoder.rb +59 -0
  13. data/lib/cassandra/client/null_logger.rb +37 -0
  14. data/lib/cassandra/client/peer_discovery.rb +50 -0
  15. data/lib/cassandra/client/prepared_statement.rb +314 -0
  16. data/lib/cassandra/client/query_result.rb +230 -0
  17. data/lib/cassandra/client/request_runner.rb +71 -0
  18. data/lib/cassandra/client/result_metadata.rb +48 -0
  19. data/lib/cassandra/client/void_result.rb +78 -0
  20. data/lib/cassandra/client.rb +144 -0
  21. data/lib/cassandra/cluster/client.rb +768 -0
  22. data/lib/cassandra/cluster/connector.rb +244 -0
  23. data/lib/cassandra/cluster/control_connection.rb +425 -0
  24. data/lib/cassandra/cluster/metadata.rb +124 -0
  25. data/lib/cassandra/cluster/options.rb +42 -0
  26. data/lib/cassandra/cluster/registry.rb +198 -0
  27. data/lib/cassandra/cluster/schema/partitioners/murmur3.rb +47 -0
  28. data/lib/cassandra/cluster/schema/partitioners/ordered.rb +37 -0
  29. data/lib/cassandra/cluster/schema/partitioners/random.rb +37 -0
  30. data/lib/cassandra/cluster/schema/partitioners.rb +21 -0
  31. data/lib/cassandra/cluster/schema/replication_strategies/network_topology.rb +92 -0
  32. data/lib/cassandra/cluster/schema/replication_strategies/none.rb +39 -0
  33. data/lib/cassandra/cluster/schema/replication_strategies/simple.rb +44 -0
  34. data/lib/cassandra/cluster/schema/replication_strategies.rb +21 -0
  35. data/lib/cassandra/cluster/schema/type_parser.rb +138 -0
  36. data/lib/cassandra/cluster/schema.rb +340 -0
  37. data/lib/cassandra/cluster.rb +215 -0
  38. data/lib/cassandra/column.rb +92 -0
  39. data/lib/cassandra/compression/compressors/lz4.rb +72 -0
  40. data/lib/cassandra/compression/compressors/snappy.rb +66 -0
  41. data/lib/cassandra/compression.rb +66 -0
  42. data/lib/cassandra/driver.rb +111 -0
  43. data/lib/cassandra/errors.rb +79 -0
  44. data/lib/cassandra/execution/info.rb +51 -0
  45. data/lib/cassandra/execution/options.rb +80 -0
  46. data/lib/cassandra/execution/trace.rb +152 -0
  47. data/lib/cassandra/future.rb +675 -0
  48. data/lib/cassandra/host.rb +79 -0
  49. data/lib/cassandra/keyspace.rb +133 -0
  50. data/lib/cassandra/listener.rb +87 -0
  51. data/lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb +149 -0
  52. data/lib/cassandra/load_balancing/policies/round_robin.rb +132 -0
  53. data/lib/cassandra/load_balancing/policies/token_aware.rb +119 -0
  54. data/lib/cassandra/load_balancing/policies/white_list.rb +90 -0
  55. data/lib/cassandra/load_balancing/policies.rb +19 -0
  56. data/lib/cassandra/load_balancing.rb +113 -0
  57. data/lib/cassandra/protocol/cql_byte_buffer.rb +307 -0
  58. data/lib/cassandra/protocol/cql_protocol_handler.rb +323 -0
  59. data/lib/cassandra/protocol/frame_decoder.rb +128 -0
  60. data/lib/cassandra/protocol/frame_encoder.rb +48 -0
  61. data/lib/cassandra/protocol/request.rb +38 -0
  62. data/lib/cassandra/protocol/requests/auth_response_request.rb +47 -0
  63. data/lib/cassandra/protocol/requests/batch_request.rb +76 -0
  64. data/lib/cassandra/protocol/requests/credentials_request.rb +47 -0
  65. data/lib/cassandra/protocol/requests/execute_request.rb +103 -0
  66. data/lib/cassandra/protocol/requests/options_request.rb +39 -0
  67. data/lib/cassandra/protocol/requests/prepare_request.rb +50 -0
  68. data/lib/cassandra/protocol/requests/query_request.rb +153 -0
  69. data/lib/cassandra/protocol/requests/register_request.rb +38 -0
  70. data/lib/cassandra/protocol/requests/startup_request.rb +49 -0
  71. data/lib/cassandra/protocol/requests/void_query_request.rb +24 -0
  72. data/lib/cassandra/protocol/response.rb +38 -0
  73. data/lib/cassandra/protocol/responses/auth_challenge_response.rb +41 -0
  74. data/lib/cassandra/protocol/responses/auth_success_response.rb +41 -0
  75. data/lib/cassandra/protocol/responses/authenticate_response.rb +41 -0
  76. data/lib/cassandra/protocol/responses/detailed_error_response.rb +60 -0
  77. data/lib/cassandra/protocol/responses/error_response.rb +50 -0
  78. data/lib/cassandra/protocol/responses/event_response.rb +39 -0
  79. data/lib/cassandra/protocol/responses/prepared_result_response.rb +64 -0
  80. data/lib/cassandra/protocol/responses/raw_rows_result_response.rb +43 -0
  81. data/lib/cassandra/protocol/responses/ready_response.rb +44 -0
  82. data/lib/cassandra/protocol/responses/result_response.rb +48 -0
  83. data/lib/cassandra/protocol/responses/rows_result_response.rb +139 -0
  84. data/lib/cassandra/protocol/responses/schema_change_event_response.rb +60 -0
  85. data/lib/cassandra/protocol/responses/schema_change_result_response.rb +57 -0
  86. data/lib/cassandra/protocol/responses/set_keyspace_result_response.rb +42 -0
  87. data/lib/cassandra/protocol/responses/status_change_event_response.rb +44 -0
  88. data/lib/cassandra/protocol/responses/supported_response.rb +41 -0
  89. data/lib/cassandra/protocol/responses/topology_change_event_response.rb +34 -0
  90. data/lib/cassandra/protocol/responses/void_result_response.rb +39 -0
  91. data/lib/cassandra/protocol/type_converter.rb +384 -0
  92. data/lib/cassandra/protocol.rb +93 -0
  93. data/lib/cassandra/reconnection/policies/constant.rb +48 -0
  94. data/lib/cassandra/reconnection/policies/exponential.rb +79 -0
  95. data/lib/cassandra/reconnection/policies.rb +20 -0
  96. data/lib/cassandra/reconnection.rb +49 -0
  97. data/lib/cassandra/result.rb +215 -0
  98. data/lib/cassandra/retry/policies/default.rb +47 -0
  99. data/lib/cassandra/retry/policies/downgrading_consistency.rb +71 -0
  100. data/lib/cassandra/retry/policies/fallthrough.rb +39 -0
  101. data/lib/cassandra/retry/policies.rb +21 -0
  102. data/lib/cassandra/retry.rb +142 -0
  103. data/lib/cassandra/session.rb +202 -0
  104. data/lib/cassandra/statement.rb +22 -0
  105. data/lib/cassandra/statements/batch.rb +95 -0
  106. data/lib/cassandra/statements/bound.rb +48 -0
  107. data/lib/cassandra/statements/prepared.rb +81 -0
  108. data/lib/cassandra/statements/simple.rb +58 -0
  109. data/lib/cassandra/statements/void.rb +33 -0
  110. data/lib/cassandra/statements.rb +23 -0
  111. data/lib/cassandra/table.rb +299 -0
  112. data/lib/cassandra/time_uuid.rb +142 -0
  113. data/lib/cassandra/util.rb +167 -0
  114. data/lib/cassandra/uuid.rb +104 -0
  115. data/lib/cassandra/version.rb +21 -0
  116. data/lib/cassandra.rb +428 -0
  117. data/lib/cassandra_murmur3.jar +0 -0
  118. metadata +211 -0
@@ -0,0 +1,72 @@
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
+ module Client
21
+ # @private
22
+ class ConnectionManager
23
+ include Enumerable
24
+
25
+ def initialize
26
+ @connections = []
27
+ @lock = Mutex.new
28
+ end
29
+
30
+ def add_connections(connections)
31
+ @lock.synchronize do
32
+ @connections.concat(connections)
33
+ connections.each do |connection|
34
+ connection.on_closed do
35
+ @lock.synchronize do
36
+ @connections.delete(connection)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def connected?
44
+ @lock.synchronize do
45
+ @connections.any?
46
+ end
47
+ end
48
+
49
+ def snapshot
50
+ @lock.synchronize do
51
+ @connections.dup
52
+ end
53
+ end
54
+
55
+ def random_connection
56
+ raise Errors::NotConnectedError unless connected?
57
+ @lock.synchronize do
58
+ @connections.sample
59
+ end
60
+ end
61
+
62
+ def each_connection(&callback)
63
+ return self unless block_given?
64
+ raise Errors::NotConnectedError unless connected?
65
+ @lock.synchronize do
66
+ @connections.each(&callback)
67
+ end
68
+ end
69
+ alias_method :each, :each_connection
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,277 @@
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
+ module Client
21
+ # @private
22
+ class ClusterConnector
23
+ def initialize(sequence, logger)
24
+ @sequence = sequence
25
+ @logger = logger
26
+ end
27
+
28
+ def connect_all(hosts, connections_per_node)
29
+ connections = hosts.flat_map do |host|
30
+ Array.new(connections_per_node) do
31
+ f = @sequence.connect(host)
32
+ f.on_value { |connection| register_logging(connection) }
33
+ f.recover do |error|
34
+ @logger.warn('Failed connecting to node at %s: %s' % [host, error.message])
35
+ FailedConnection.new(error, host)
36
+ end
37
+ end
38
+ end
39
+ Ione::Future.all(*connections).map do |connections|
40
+ connected_connections = connections.select(&:connected?)
41
+ if connected_connections.empty?
42
+ e = connections.first.error
43
+ if e.is_a?(Cassandra::Errors::QueryError) && e.code == 0x100
44
+ e = Errors::AuthenticationError.new(e.message)
45
+ end
46
+ raise e
47
+ end
48
+ connected_connections
49
+ end
50
+ end
51
+
52
+ private
53
+
54
+ def register_logging(connection)
55
+ args = [connection[:host_id], connection.host, connection.port, connection[:data_center]]
56
+ @logger.info('Connected to node %s at %s:%d in data center %s' % args)
57
+ connection.on_closed do |cause|
58
+ message = 'Connection to node %s at %s:%d in data center %s closed' % args
59
+ if cause
60
+ message << (' unexpectedly: %s' % cause.message)
61
+ @logger.warn(message)
62
+ else
63
+ @logger.info(message)
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ # @private
70
+ class Connector
71
+ def initialize(steps)
72
+ @steps = steps.dup
73
+ end
74
+
75
+ def connect(host)
76
+ pending_connection = PendingConnection.new(host)
77
+ seed = Ione::Future.resolved(pending_connection)
78
+ f = @steps.reduce(seed) do |chain, step|
79
+ chain.flat_map do |pending_connection|
80
+ step.run(pending_connection)
81
+ end
82
+ end
83
+ f.map do |pending_connection|
84
+ pending_connection.connection
85
+ end
86
+ end
87
+ end
88
+
89
+ # @private
90
+ class ConnectStep
91
+ def initialize(io_reactor, protocol_handler_factory, port, connection_options, logger)
92
+ @io_reactor = io_reactor
93
+ @protocol_handler_factory = protocol_handler_factory
94
+ @port = port
95
+ @connection_options = connection_options
96
+ @logger = logger
97
+ end
98
+
99
+ def run(pending_connection)
100
+ @io_reactor.connect(pending_connection.host, @port, @connection_options, &@protocol_handler_factory).map do |connection|
101
+ pending_connection.with_connection(connection)
102
+ end
103
+ end
104
+ end
105
+
106
+ # @private
107
+ class CacheOptionsStep
108
+ def initialize(timeout = nil)
109
+ @timeout = timeout
110
+ end
111
+
112
+ def run(pending_connection)
113
+ f = pending_connection.execute(Protocol::OptionsRequest.new, @timeout)
114
+ f.on_value do |supported_options|
115
+ pending_connection[:cql_version] = supported_options['CQL_VERSION']
116
+ pending_connection[:compression] = supported_options['COMPRESSION']
117
+ end
118
+
119
+ f.map(pending_connection)
120
+ end
121
+ end
122
+
123
+ # @private
124
+ class InitializeStep
125
+ def initialize(compressor, logger)
126
+ @compressor = compressor
127
+ @logger = logger
128
+ end
129
+
130
+ def run(pending_connection)
131
+ compression = @compressor && @compressor.algorithm
132
+ supported_algorithms = pending_connection[:compression]
133
+ if compression && !supported_algorithms.include?(compression)
134
+ @logger.warn(%[Compression algorithm "#{compression}" not supported (server supports "#{supported_algorithms.join('", "')}")])
135
+ compression = nil
136
+ end
137
+ @logger.debug('Using "%s" compression' % compression) if compression
138
+ supported_cql_versions = pending_connection[:cql_version]
139
+ cql_version = (supported_cql_versions && !supported_cql_versions.empty?) ? supported_cql_versions.first : '3.1.0'
140
+
141
+ f = pending_connection.execute(Protocol::StartupRequest.new(cql_version, compression))
142
+ f.map do |startup_response|
143
+ if startup_response.is_a?(AuthenticationRequired)
144
+ pending_connection.with_authentication_class(startup_response.authentication_class)
145
+ else
146
+ pending_connection
147
+ end
148
+ end
149
+ end
150
+ end
151
+
152
+ # @private
153
+ class SaslAuthenticationStep
154
+ def initialize(auth_provider)
155
+ @auth_provider = auth_provider
156
+ end
157
+
158
+ def run(pending_connection)
159
+ if pending_connection.authentication_class
160
+ begin
161
+ authenticator = @auth_provider && @auth_provider.create_authenticator(pending_connection.authentication_class)
162
+ if authenticator
163
+ token = authenticator.initial_response
164
+ challenge_cycle(pending_connection, authenticator, token)
165
+ elsif @auth_provider
166
+ Ione::Future.failed(Errors::AuthenticationError.new('Auth provider does not support the required authentication class "%s" and/or protocol version %d' % [pending_connection.authentication_class, @protocol_version]))
167
+ else
168
+ Ione::Future.failed(Errors::AuthenticationError.new('Server requested authentication, but no auth provider found'))
169
+ end
170
+ rescue => e
171
+ Ione::Future.failed(Errors::AuthenticationError.new('Auth provider raised an error: %s' % e.message))
172
+ end
173
+ else
174
+ Ione::Future.resolved(pending_connection)
175
+ end
176
+ end
177
+
178
+ def challenge_cycle(pending_connection, authenticator, response_token)
179
+ request = Protocol::AuthResponseRequest.new(response_token)
180
+ f = pending_connection.execute(request) { |raw_response| raw_response }
181
+ f.flat_map do |response|
182
+ case response
183
+ when Protocol::AuthChallengeResponse
184
+ token = authenticator.challenge_response(response.token)
185
+ challenge_cycle(pending_connection, authenticator, token)
186
+ when Protocol::AuthSuccessResponse
187
+ authenticator.authentication_successful(response.token) rescue nil
188
+ Ione::Future.resolved(pending_connection)
189
+ else
190
+ Ione::Future.resolved(pending_connection)
191
+ end
192
+ end
193
+ end
194
+ end
195
+
196
+ # @private
197
+ class CredentialsAuthenticationStep
198
+ def initialize(credentials)
199
+ @credentials = credentials
200
+ end
201
+
202
+ def run(pending_connection)
203
+ if pending_connection.authentication_class
204
+ if @credentials
205
+ request = Protocol::CredentialsRequest.new(@credentials)
206
+ pending_connection.execute(request).map(pending_connection)
207
+ else
208
+ Ione::Future.failed(Errors::AuthenticationError.new('Server requested authentication, but no credentials provided'))
209
+ end
210
+ else
211
+ Ione::Future.resolved(pending_connection)
212
+ end
213
+ end
214
+ end
215
+
216
+ # @private
217
+ class CachePropertiesStep
218
+ def run(pending_connection)
219
+ request = Protocol::QueryRequest.new('SELECT data_center, host_id FROM system.local', nil, nil, :one)
220
+ f = pending_connection.execute(request)
221
+ f.on_value do |result|
222
+ unless result.empty?
223
+ pending_connection[:host_id] = result.first['host_id']
224
+ pending_connection[:data_center] = result.first['data_center']
225
+ end
226
+ end
227
+ f.map(pending_connection)
228
+ end
229
+ end
230
+
231
+ # @private
232
+ class PendingConnection
233
+ attr_reader :host, :connection, :authentication_class
234
+
235
+ def initialize(host, connection=nil, authentication_class=nil)
236
+ @host = host
237
+ @connection = connection
238
+ @authentication_class = authentication_class
239
+ @request_runner = RequestRunner.new
240
+ end
241
+
242
+ def with_connection(connection)
243
+ self.class.new(host, connection, @authentication_class)
244
+ end
245
+
246
+ def with_authentication_class(authentication_class)
247
+ self.class.new(host, @connection, authentication_class)
248
+ end
249
+
250
+ def [](key)
251
+ @connection[key]
252
+ end
253
+
254
+ def []=(key, value)
255
+ @connection[key] = value
256
+ end
257
+
258
+ def execute(request, timeout = nil, &block)
259
+ @request_runner.execute(@connection, request, timeout, nil, &block)
260
+ end
261
+ end
262
+
263
+ # @private
264
+ class FailedConnection
265
+ attr_reader :error, :host
266
+
267
+ def initialize(error, host)
268
+ @error = error
269
+ @host = host
270
+ end
271
+
272
+ def connected?
273
+ false
274
+ end
275
+ end
276
+ end
277
+ end
@@ -0,0 +1,59 @@
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
+ module Client
21
+ # @private
22
+ class ExecuteOptionsDecoder
23
+ def initialize(default_consistency)
24
+ @default_consistency = default_consistency
25
+ @default_options = {:consistency => @default_consistency}.freeze
26
+ end
27
+
28
+ def decode_options(*args)
29
+ if args.empty?
30
+ @default_options
31
+ elsif args.size == 1
32
+ decode_one(args.first)
33
+ else
34
+ args.each_with_object({}) do |options_or_consistency, result|
35
+ result.merge!(decode_one(options_or_consistency))
36
+ end
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def decode_one(options_or_consistency)
43
+ return @default_options unless options_or_consistency
44
+ case options_or_consistency
45
+ when Symbol
46
+ {:consistency => options_or_consistency}
47
+ when Hash
48
+ if options_or_consistency.include?(:consistency)
49
+ options_or_consistency
50
+ else
51
+ options = options_or_consistency.dup
52
+ options[:consistency] = @default_consistency
53
+ options
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,37 @@
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
+ module Client
21
+ # @private
22
+ class NullLogger
23
+ def close(*); end
24
+ def debug(*); end
25
+ def debug?; false end
26
+ def error(*); end
27
+ def error?; false end
28
+ def fatal(*); end
29
+ def fatal?; false end
30
+ def info(*); end
31
+ def info?; false end
32
+ def unknown(*); end
33
+ def warn(*); end
34
+ def warn?; false end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,50 @@
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
+ module Client
21
+ # @private
22
+ class PeerDiscovery
23
+ def initialize(seed_connections)
24
+ @seed_connections = seed_connections
25
+ @connection = seed_connections.sample
26
+ @request_runner = RequestRunner.new
27
+ end
28
+
29
+ def new_hosts
30
+ request = Protocol::QueryRequest.new('SELECT peer, data_center, host_id, rpc_address FROM system.peers', nil, nil, :one)
31
+ response = @request_runner.execute(@connection, request)
32
+ response.map do |result|
33
+ result.each_with_object([]) do |row, new_peers|
34
+ if include?(row['host_id'], row['data_center'])
35
+ rpc_address = row['rpc_address'].to_s
36
+ rpc_address = row['peer'].to_s if rpc_address == '0.0.0.0'
37
+ new_peers << rpc_address
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def include?(host_id, dc)
46
+ @seed_connections.any? { |c| c[:data_center] == dc } && @seed_connections.none? { |c| c[:host_id] == host_id }
47
+ end
48
+ end
49
+ end
50
+ end