25
26
27
28
29
30
31
32
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
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/aerospike/node/refresh/peers.rb', line 25
def call(node, peers)
return unless should_refresh?(node)
::Aerospike.logger.debug("Update peers for node #{node.name}")
cluster = node.cluster
collection = ::Aerospike::Peers::Fetch.(cluster, node.tend_connection)
peers.peers = collection.peers
node.peers_count.value = peers.peers.size
peers_validated = true
peers.peers.each do |peer|
next if ::Aerospike::Cluster::FindNode.(cluster, peers, peer.node_name)
node_validated = false
peer.hosts.each do |host|
begin
nv = NodeValidator.new(cluster, host, cluster.connection_timeout, cluster.cluster_name, cluster.tls_options)
if nv.name != peer.node_name
::Aerospike.logger.warn("Peer node #{peer.node_name} is different than actual node #{nv.name} for host #{host}");
if Cluster::FindNode.(cluster, peers, nv.name)
node_validated = true
break;
end
end
new_node = cluster.create_node(nv)
peers.nodes[nv.name] = new_node
node_validated = true
break;
rescue ::Aerospike::Exceptions::Aerospike => e
Aerospike.logger.warn("Add node #{host} failed: #{e.inspect}")
end
peers_validated = false unless node_validated
end
end
node.peers_generation.update(collection.generation) if peers_validated
peers.refresh_count += 1
rescue ::Aerospike::Exceptions::Aerospike => e
Refresh::Failed.(node, e)
end
|