Class: Aerospike::Cluster
- Inherits:
-
Object
- Object
- Aerospike::Cluster
show all
- Defined in:
- lib/aerospike/cluster.rb,
lib/aerospike/cluster/find_node.rb,
lib/aerospike/cluster/create_connection.rb,
lib/aerospike/cluster/find_nodes_to_remove.rb
Defined Under Namespace
Modules: CreateConnection, FindNode, FindNodesToRemove
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#add_alias(host, node) ⇒ Object
-
#add_aliases(node) ⇒ Object
-
#add_cluster_config_change_listener(listener) ⇒ Object
-
#add_nodes(nodes_to_add) ⇒ Object
-
#add_nodes_copy(nodes_to_add) ⇒ Object
-
#add_seeds(hosts) ⇒ Object
-
#batch_read_node(partition, replica_policy) ⇒ Object
Returns a node on the cluster for read operations.
-
#change_password(user, password) ⇒ Object
-
#close ⇒ Object
Closes all cached connections to the cluster nodes and stops the tend thread.
-
#connect ⇒ Object
-
#connected? ⇒ Boolean
-
#create_connection(host) ⇒ Object
-
#create_node(nv) ⇒ Object
-
#credentials_given? ⇒ Boolean
-
#find_alias(aliass) ⇒ Object
-
#find_node_by_name(node_name) ⇒ Object
-
#find_node_in_partition_map(filter) ⇒ Object
-
#find_node_name(list, name) ⇒ Object
Finds a node by name in a list of nodes.
-
#find_nodes_to_remove(refresh_count) ⇒ Object
-
#get_node_by_name(node_name) ⇒ Object
Find a node by name and returns an error if not found.
-
#get_node_for_key(replica_policy, key) ⇒ Object
-
#initialize(policy, hosts) ⇒ Cluster
constructor
A new instance of Cluster.
-
#initialize_tls_host_names(hosts) ⇒ Object
-
#inspect ⇒ Object
-
#launch_tend_thread ⇒ Object
-
#log_tend_stats(nodes) ⇒ Object
-
#master_node(partition) ⇒ Object
Returns a node on the cluster for read operations.
-
#master_proles_node(partition) ⇒ Object
Returns a node on the cluster for read operations.
-
#node_exists(search, node_list) ⇒ Object
-
#nodes ⇒ Object
Returns a list of all nodes in the cluster.
-
#notify_cluster_config_changed ⇒ Object
-
#partitions ⇒ Object
-
#rack_node(partition, seq) ⇒ Object
Returns a node on the cluster.
-
#random_node ⇒ Object
Returns a random node on the cluster.
-
#read_node(partition, replica_policy, seq) ⇒ Object
Returns a node on the cluster for read operations.
-
#refresh_nodes ⇒ Object
Refresh status of all nodes in cluster.
-
#remove_alias(aliass) ⇒ Object
-
#remove_cluster_config_change_listener(listener) ⇒ Object
-
#remove_nodes(nodes_to_remove) ⇒ Object
-
#remove_nodes_copy(nodes_to_remove) ⇒ Object
-
#request_info(policy, *commands) ⇒ Object
-
#request_node_info(node, policy, *commands) ⇒ Object
-
#seed_nodes ⇒ Object
-
#seeds ⇒ Object
-
#sequence_node(partition, seq) ⇒ Object
Returns a random node on the cluster.
-
#set_nodes(nodes) ⇒ Object
-
#set_partitions(part_map) ⇒ Object
-
#supports_feature?(feature) ⇒ Boolean
-
#supports_peers_protocol? ⇒ Boolean
-
#tend ⇒ Object
Check health of all nodes in cluster.
-
#tls_enabled? ⇒ Boolean
-
#update_cluster_features ⇒ Object
-
#update_partitions(parser) ⇒ Object
-
#wait_till_stablized ⇒ Object
Constructor Details
#initialize(policy, hosts) ⇒ Cluster
Returns a new instance of Cluster.
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/aerospike/cluster.rb', line 33
def initialize(policy, hosts)
@cluster_seeds = hosts
@fail_if_not_connected = policy.fail_if_not_connected
@connection_queue_size = policy.connection_queue_size
@connection_timeout = policy.timeout
@tend_interval = policy.tend_interval
@cluster_name = policy.cluster_name
@tls_options = policy.tls
@rack_aware = policy.rack_aware
@rack_id = policy.rack_id
@replica_index = Atomic.new(0)
@aliases = {}
@cluster_nodes = []
@partition_write_map = {}
@node_index = Atomic.new(0)
@features = Atomic.new(Set.new)
@closed = Atomic.new(true)
@mutex = Mutex.new
@cluster_config_change_listeners = Atomic.new([])
@old_node_count = 0
if policy.requires_authentication
@user = policy.user
@password = AdminCommand.hash_password(policy.password)
end
initialize_tls_host_names(hosts) if tls_enabled?
end
|
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
29
30
31
|
# File 'lib/aerospike/cluster.rb', line 29
def aliases
@aliases
end
|
#cluster_id ⇒ Object
Returns the value of attribute cluster_id.
29
30
31
|
# File 'lib/aerospike/cluster.rb', line 29
def cluster_id
@cluster_id
end
|
#cluster_name ⇒ Object
Returns the value of attribute cluster_name.
30
31
32
|
# File 'lib/aerospike/cluster.rb', line 30
def cluster_name
@cluster_name
end
|
#connection_queue_size ⇒ Object
Returns the value of attribute connection_queue_size.
27
28
29
|
# File 'lib/aerospike/cluster.rb', line 27
def connection_queue_size
@connection_queue_size
end
|
#connection_timeout ⇒ Object
Returns the value of attribute connection_timeout.
27
28
29
|
# File 'lib/aerospike/cluster.rb', line 27
def connection_timeout
@connection_timeout
end
|
#features ⇒ Object
Returns the value of attribute features.
28
29
30
|
# File 'lib/aerospike/cluster.rb', line 28
def features
@features
end
|
#password ⇒ Object
Returns the value of attribute password.
27
28
29
|
# File 'lib/aerospike/cluster.rb', line 27
def password
@password
end
|
#rack_aware ⇒ Object
Returns the value of attribute rack_aware.
31
32
33
|
# File 'lib/aerospike/cluster.rb', line 31
def rack_aware
@rack_aware
end
|
#rack_id ⇒ Object
Returns the value of attribute rack_id.
31
32
33
|
# File 'lib/aerospike/cluster.rb', line 31
def rack_id
@rack_id
end
|
#tls_options ⇒ Object
Returns the value of attribute tls_options.
28
29
30
|
# File 'lib/aerospike/cluster.rb', line 28
def tls_options
@tls_options
end
|
#user ⇒ Object
Returns the value of attribute user.
27
28
29
|
# File 'lib/aerospike/cluster.rb', line 27
def user
@user
end
|
Instance Method Details
#add_alias(host, node) ⇒ Object
533
534
535
536
537
538
539
|
# File 'lib/aerospike/cluster.rb', line 533
def add_alias(host, node)
if host && node
@mutex.synchronize do
@aliases[host] = node
end
end
end
|
#add_aliases(node) ⇒ Object
581
582
583
584
585
586
587
|
# File 'lib/aerospike/cluster.rb', line 581
def add_aliases(node)
node.aliases.each do |aliass|
@aliases[aliass] = node
end
end
|
#add_cluster_config_change_listener(listener) ⇒ Object
318
319
320
321
322
|
# File 'lib/aerospike/cluster.rb', line 318
def add_cluster_config_change_listener(listener)
@cluster_config_change_listeners.update do |listeners|
listeners.push(listener)
end
end
|
#add_nodes(nodes_to_add) ⇒ Object
572
573
574
575
576
577
578
579
|
# File 'lib/aerospike/cluster.rb', line 572
def add_nodes(nodes_to_add)
nodes_to_add.each do |node|
add_aliases(node)
end
add_nodes_copy(nodes_to_add)
end
|
#add_nodes_copy(nodes_to_add) ⇒ Object
589
590
591
592
593
|
# File 'lib/aerospike/cluster.rb', line 589
def add_nodes_copy(nodes_to_add)
@mutex.synchronize do
@cluster_nodes.concat(nodes_to_add)
end
end
|
#add_seeds(hosts) ⇒ Object
92
93
94
95
96
|
# File 'lib/aerospike/cluster.rb', line 92
def add_seeds(hosts)
@mutex.synchronize do
@cluster_seeds.concat(hosts)
end
end
|
#batch_read_node(partition, replica_policy) ⇒ Object
Returns a node on the cluster for read operations
#change_password(user, password) ⇒ Object
313
314
315
316
|
# File 'lib/aerospike/cluster.rb', line 313
def change_password(user, password)
@password = password if @user == user
end
|
#close ⇒ Object
Closes all cached connections to the cluster nodes and stops the tend thread
270
271
272
273
274
275
276
277
|
# File 'lib/aerospike/cluster.rb', line 270
def close
return if @closed.value
@closed.value = true
@tend_thread.kill
nodes.each(&:close)
end
|
#connected? ⇒ Boolean
104
105
106
107
108
|
# File 'lib/aerospike/cluster.rb', line 104
def connected?
node_array = nodes
(node_array.length > 0) && !@closed.value
end
|
#create_connection(host) ⇒ Object
#create_node(nv) ⇒ Object
549
550
551
|
# File 'lib/aerospike/cluster.rb', line 549
def create_node(nv)
::Aerospike::Node.new(self, nv)
end
|
#credentials_given? ⇒ Boolean
78
79
80
|
# File 'lib/aerospike/cluster.rb', line 78
def credentials_given?
!(@user.nil? || @user.empty?)
end
|
#find_alias(aliass) ⇒ Object
279
280
281
282
283
|
# File 'lib/aerospike/cluster.rb', line 279
def find_alias(aliass)
@mutex.synchronize do
@aliases[aliass]
end
end
|
#find_node_by_name(node_name) ⇒ Object
657
658
659
|
# File 'lib/aerospike/cluster.rb', line 657
def find_node_by_name(node_name)
nodes.detect{|node| node.name == node_name }
end
|
#find_node_in_partition_map(filter) ⇒ Object
561
562
563
564
565
566
567
568
569
570
|
# File 'lib/aerospike/cluster.rb', line 561
def find_node_in_partition_map(filter)
partitions_list = partitions
partitions_list.values.each do |replica_array|
replica_array.get.each do |node_array|
return true if node_array.value.any? { |node| node == filter }
end
end
false
end
|
#find_node_name(list, name) ⇒ Object
Finds a node by name in a list of nodes
529
530
531
|
# File 'lib/aerospike/cluster.rb', line 529
def find_node_name(list, name)
list.any? { |node| node.name == name }
end
|
#find_nodes_to_remove(refresh_count) ⇒ Object
557
558
559
|
# File 'lib/aerospike/cluster.rb', line 557
def find_nodes_to_remove(refresh_count)
FindNodesToRemove.(self, refresh_count)
end
|
#get_node_by_name(node_name) ⇒ Object
Find a node by name and returns an error if not found
261
262
263
264
265
266
267
|
# File 'lib/aerospike/cluster.rb', line 261
def get_node_by_name(node_name)
node = find_node_by_name(node_name)
raise Aerospike::Exceptions::InvalidNode unless node
node
end
|
#get_node_for_key(replica_policy, key) ⇒ Object
229
230
231
232
|
# File 'lib/aerospike/cluster.rb', line 229
def get_node_for_key(replica_policy, key)
partition = Partition.new_by_key(key)
batch_read_node(partition, replica_policy)
end
|
#initialize_tls_host_names(hosts) ⇒ Object
86
87
88
89
90
|
# File 'lib/aerospike/cluster.rb', line 86
def initialize_tls_host_names(hosts)
hosts.each do |host|
host.tls_name ||= cluster_id.nil? ? host.name : cluster_id
end
end
|
#inspect ⇒ Object
330
331
332
|
# File 'lib/aerospike/cluster.rb', line 330
def inspect
"#<Aerospike::Cluster @cluster_nodes=#{@cluster_nodes}>"
end
|
#launch_tend_thread ⇒ Object
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
# File 'lib/aerospike/cluster.rb', line 334
def launch_tend_thread
@tend_thread = Thread.new do
Thread.current.abort_on_exception = false
loop do
begin
tend
sleep(@tend_interval / 1000.0)
rescue => e
Aerospike.logger.error("Exception occured during tend: #{e}")
Aerospike.logger.debug { e.backtrace.join("\n") }
end
end
end
end
|
#log_tend_stats(nodes) ⇒ Object
422
423
424
425
426
427
|
# File 'lib/aerospike/cluster.rb', line 422
def log_tend_stats(nodes)
diff = nodes.size - @old_node_count
action = "#{diff.abs} #{diff.abs == 1 ? "node has" : "nodes have"} #{diff > 0 ? "joined" : "left"} the cluster."
Aerospike.logger.info("Tend finished. #{action} Old node count: #{@old_node_count}, New node count: #{nodes.size}")
@old_node_count = nodes.size
end
|
#master_node(partition) ⇒ Object
Returns a node on the cluster for read operations
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/aerospike/cluster.rb', line 145
def master_node(partition)
partition_map = partitions
replica_array = partition_map[partition.namespace]
raise Aerospike::Exceptions::InvalidNamespace("namespace not found in the partition map") if !replica_array
node_array = (replica_array.get)[0]
raise Aerospike::Exceptions::InvalidNamespace("namespace not found in the partition map") if !node_array
node = (node_array.get)[partition.partition_id]
raise Aerospike::Exceptions::InvalidNode if !node || !node.active?
node
end
|
#master_proles_node(partition) ⇒ Object
Returns a node on the cluster for read operations
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/aerospike/cluster.rb', line 192
def master_proles_node(partition)
partition_map = partitions
replica_array = partition_map[partition.namespace]
raise Aerospike::Exceptions::InvalidNamespace("namespace not found in the partition map") if !replica_array
replica_array = replica_array.get
node = nil
for replica in replica_array
idx = (@replica_index.update{|v| v.succ} % replica_array.size).abs
node = (replica_array[idx].get)[partition.partition_id]
return node if node && node.active?
end
raise Aerospike::Exceptions::InvalidNode
end
|
#node_exists(search, node_list) ⇒ Object
653
654
655
|
# File 'lib/aerospike/cluster.rb', line 653
def node_exists(search, node_list)
node_list.any? {|node| node == search }
end
|
#nodes ⇒ Object
Returns a list of all nodes in the cluster
253
254
255
256
257
258
|
# File 'lib/aerospike/cluster.rb', line 253
def nodes
@mutex.synchronize do
@cluster_nodes.dup
end
end
|
#notify_cluster_config_changed ⇒ Object
467
468
469
470
471
472
|
# File 'lib/aerospike/cluster.rb', line 467
def notify_cluster_config_changed
listeners = @cluster_config_change_listeners.get
listeners.each do |listener|
listener.send(:cluster_config_changed, self)
end
end
|
#partitions ⇒ Object
480
481
482
483
484
485
486
487
|
# File 'lib/aerospike/cluster.rb', line 480
def partitions
res = nil
@mutex.synchronize do
res = @partition_write_map
end
res
end
|
#rack_node(partition, seq) ⇒ Object
Returns a node on the cluster
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/aerospike/cluster.rb', line 160
def rack_node(partition, seq)
partition_map = partitions
replica_array = partition_map[partition.namespace]
raise Aerospike::Exceptions::InvalidNamespace("namespace not found in the partition map") if !replica_array
replica_array = replica_array.get
is_retry = seq.value > -1
node = nil
fallback = nil
for i in 1..replica_array.length
idx = (seq.update{|v| v.succ} % replica_array.size).abs
node = (replica_array[idx].get)[partition.partition_id]
next if !node
fallback = node
return fallback if is_retry && fallback && i == replica_array.length
return node if node && node.active? && node.has_rack(partition.namespace, @rack_id)
end
return fallback if fallback
raise Aerospike::Exceptions::InvalidNode
end
|
#random_node ⇒ Object
Returns a random node on the cluster
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# File 'lib/aerospike/cluster.rb', line 235
def random_node
node_array = nodes
length = node_array.length
i = 0
while i < length
idx = (@node_index.update{ |v| v.succ } % node_array.length).abs
node = node_array[idx]
return node if node.active?
i = i.succ
end
raise Aerospike::Exceptions::InvalidNode
end
|
#read_node(partition, replica_policy, seq) ⇒ Object
Returns a node on the cluster for read operations
#refresh_nodes ⇒ Object
Refresh status of all nodes in cluster. Adds new nodes and/or removes unhealty ones
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
# File 'lib/aerospike/cluster.rb', line 364
def refresh_nodes
cluster_config_changed = false
nodes = self.nodes
if nodes.empty?
seed_nodes
cluster_config_changed = true
nodes = self.nodes
end
peers = Peers.new
nodes.each do |node|
node.refresh_reset
end
peers.use_peers = supports_peers_protocol?
nodes.each do |node|
node.refresh_info(peers)
end
if peers.generation_changed?
peers.reset_refresh_count!
nodes.each do |node|
node.refresh_peers(peers)
end
end
nodes.each do |node|
node.refresh_partitions(peers) if node.partition_generation.changed?
node.refresh_racks if node.rebalance_generation.changed?
end
if peers.generation_changed? || !peers.use_peers?
nodes_to_remove = find_nodes_to_remove(peers.refresh_count)
if nodes_to_remove.any?
remove_nodes(nodes_to_remove)
cluster_config_changed = true
end
end
if peers.nodes.any?
add_nodes(peers.nodes.values)
cluster_config_changed = true
end
cluster_config_changed
end
|
#remove_alias(aliass) ⇒ Object
541
542
543
544
545
546
547
|
# File 'lib/aerospike/cluster.rb', line 541
def remove_alias(aliass)
if aliass
@mutex.synchronize do
@aliases.delete(aliass)
end
end
end
|
#remove_cluster_config_change_listener(listener) ⇒ Object
324
325
326
327
328
|
# File 'lib/aerospike/cluster.rb', line 324
def remove_cluster_config_change_listener(listener)
@cluster_config_change_listeners.update do |listeners|
listeners.delete(listener)
end
end
|
#remove_nodes(nodes_to_remove) ⇒ Object
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
|
# File 'lib/aerospike/cluster.rb', line 595
def remove_nodes(nodes_to_remove)
nodes_to_remove.each do |node|
node.aliases.each do |aliass|
Aerospike.logger.debug("Removing alias #{aliass}")
remove_alias(aliass)
end
node.close
end
remove_nodes_copy(nodes_to_remove)
end
|
#remove_nodes_copy(nodes_to_remove) ⇒ Object
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
# File 'lib/aerospike/cluster.rb', line 623
def remove_nodes_copy(nodes_to_remove)
nodes_list = nodes
node_array = []
count = 0
nodes_list.each do |node|
if node_exists(node, nodes_to_remove)
Aerospike.logger.info("Removed node `#{node}`")
else
node_array[count] = node
count += 1
end
end
if count < node_array.length
Aerospike.logger.warn("Node remove mismatch. Expected #{node_array.length}, Received #{count}")
node_array = node_array.dup[0..count-1]
end
set_nodes(node_array)
end
|
#request_info(policy, *commands) ⇒ Object
290
291
292
293
294
295
296
|
# File 'lib/aerospike/cluster.rb', line 290
def request_info(policy, *commands)
node = random_node
conn = node.get_connection(policy.timeout)
Info.request(conn, *commands).tap do
node.put_connection(conn)
end
end
|
#request_node_info(node, policy, *commands) ⇒ Object
298
299
300
301
302
303
|
# File 'lib/aerospike/cluster.rb', line 298
def request_node_info(node, policy, *commands)
conn = node.get_connection(policy.timeout)
Info.request(conn, *commands).tap do
node.put_connection(conn)
end
end
|
#seed_nodes ⇒ Object
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
|
# File 'lib/aerospike/cluster.rb', line 489
def seed_nodes
seed_array = seeds
Aerospike.logger.info("Seeding the cluster. Seeds count: #{seed_array.length}")
list = []
seed_array.each do |seed|
begin
seed_node_validator = NodeValidator.new(self, seed, @connection_timeout, @cluster_name, tls_options)
rescue => e
Aerospike.logger.error("Seed #{seed} failed: #{e}\n#{e.backtrace.join("\n")}")
next
end
nv = nil
seed_node_validator.aliases.each do |aliass|
if aliass == seed
nv = seed_node_validator
else
begin
nv = NodeValidator.new(self, aliass, @connection_timeout, @cluster_name, tls_options)
rescue => e
Aerospike.logger.error("Seed #{seed} failed: #{e}")
next
end
end
next if find_node_name(list, nv.name)
node = create_node(nv)
add_aliases(node)
list << node
end
end
add_nodes_copy(list) if list.length > 0
end
|
#seeds ⇒ Object
98
99
100
101
102
|
# File 'lib/aerospike/cluster.rb', line 98
def seeds
@mutex.synchronize do
@cluster_seeds.dup
end
end
|
#sequence_node(partition, seq) ⇒ Object
Returns a random node on the cluster
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
# File 'lib/aerospike/cluster.rb', line 211
def sequence_node(partition, seq)
partition_map = partitions
replica_array = partition_map[partition.namespace]
raise Aerospike::Exceptions::InvalidNamespace("namespace not found in the partition map") if !replica_array
replica_array = replica_array.get
node = nil
for replica in replica_array
idx = (seq.update{|v| v.succ} % replica_array.size).abs
node = (replica_array[idx].get)[partition.partition_id]
return node if node && node.active?
end
raise Aerospike::Exceptions::InvalidNode
end
|
#set_nodes(nodes) ⇒ Object
616
617
618
619
620
621
|
# File 'lib/aerospike/cluster.rb', line 616
def set_nodes(nodes)
@mutex.synchronize do
@cluster_nodes = nodes
end
end
|
#set_partitions(part_map) ⇒ Object
474
475
476
477
478
|
# File 'lib/aerospike/cluster.rb', line 474
def set_partitions(part_map)
@mutex.synchronize do
@partition_write_map = part_map
end
end
|
#supports_feature?(feature) ⇒ Boolean
305
306
307
|
# File 'lib/aerospike/cluster.rb', line 305
def supports_feature?(feature)
@features.get.include?(feature.to_s)
end
|
#supports_peers_protocol? ⇒ Boolean
309
310
311
|
# File 'lib/aerospike/cluster.rb', line 309
def supports_peers_protocol?
nodes.all? { |node| node.supports_feature?(Aerospike::Features::PEERS) }
end
|
#tend ⇒ Object
Check health of all nodes in cluster
350
351
352
353
354
355
356
357
358
359
360
|
# File 'lib/aerospike/cluster.rb', line 350
def tend
was_changed = refresh_nodes
return unless was_changed
update_cluster_features
notify_cluster_config_changed
log_tend_stats(nodes)
end
|
#tls_enabled? ⇒ Boolean
82
83
84
|
# File 'lib/aerospike/cluster.rb', line 82
def tls_enabled?
!tls_options.nil? && tls_options[:enable] != false
end
|
#update_cluster_features ⇒ Object
459
460
461
462
463
464
465
|
# File 'lib/aerospike/cluster.rb', line 459
def update_cluster_features
@features.update do
node_features = nodes.map(&:features)
node_features.reduce(&:intersection) || Set.new
end
end
|
#update_partitions(parser) ⇒ Object
285
286
287
288
|
# File 'lib/aerospike/cluster.rb', line 285
def update_partitions(parser)
nmap = parser.update_partitions(partitions)
set_partitions(nmap) if nmap
end
|
#wait_till_stablized ⇒ Object
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
|
# File 'lib/aerospike/cluster.rb', line 429
def wait_till_stablized
count = -1
thr = Thread.new do
loop do
tend
break if count == nodes.length
sleep(0.001)
count = nodes.length
end
end
begin
Timeout.timeout(@connection_timeout) do
thr.join
end
rescue Timeout::Error
thr.kill if thr.alive?
end
@closed.value = false if @cluster_nodes.length > 0
end
|