Module: Aerospike::Node::Refresh::Info

Defined in:
lib/aerospike/node/refresh/info.rb

Constant Summary collapse

CMDS_BASE =
%w[node partition-generation cluster-name].freeze
CMDS_PEERS =
(CMDS_BASE + ['peers-generation']).freeze
CMDS_SERVICES =
(CMDS_BASE + ['services']).freeze
CMDS_REBALANCE =
(CMDS_PEERS + ['rebalance-generation']).freeze

Class Method Summary collapse

Class Method Details

.call(node, peers) ⇒ Object



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
# File 'lib/aerospike/node/refresh/info.rb', line 30

def call(node, peers)
  conn = node.tend_connection
  if peers.use_peers?
    cmds = node.cluster.rack_aware ? CMDS_REBALANCE : CMDS_PEERS
    info_map = ::Aerospike::Info.request(conn, *cmds)
    Verify::PeersGeneration.(node, info_map, peers)
    Verify::PartitionGeneration.(node, info_map)
    Verify::RebalanceGeneration.(node, info_map) if node.cluster.rack_aware
    Verify::Name.(node, info_map)
    Verify::ClusterName.(node, info_map)
  else
    info_map = ::Aerospike::Info.request(conn, *CMDS_SERVICES)
    Verify::PartitionGeneration.(node, info_map)
    Verify::Name.(node, info_map)
    Verify::ClusterName.(node, info_map)
    Refresh::Friends.(node, peers, info_map)
  end

  node.restore_health
  node.responded!

  peers.refresh_count += 1
  node.reset_failures!
rescue ::Aerospike::Exceptions::Aerospike => e
  conn.close if conn
  node.decrease_health
  peers.generation_changed = true if peers.use_peers?
  Refresh::Failed.(node, e)
end