Module: Aerospike::Node::Refresh::Partitions

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

Class Method Summary collapse

Class Method Details

.call(node, peers) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/aerospike/node/refresh/partitions.rb', line 25

def call(node, peers)
  return unless should_refresh?(node, peers)

  Aerospike.logger.info("Updating partitions for node #{node.name}")
  conn = node.tend_connection
  parser = PartitionParser.new(node, conn)
  node.cluster.update_partitions(parser)
rescue ::Aerospike::Exceptions::Aerospike => e
  conn.close
  Refresh::Failed.(node, e)
end

.should_refresh?(node, peers) ⇒ Boolean

Do not refresh partitions when node connection has already failed during this cluster tend iteration. Also, avoid “split cluster” case where this node thinks it’s a 1-node cluster. Unchecked, such a node can dominate the partition map and cause all other nodes to be dropped.

Returns:

  • (Boolean)


42
43
44
45
46
# File 'lib/aerospike/node/refresh/partitions.rb', line 42

def should_refresh?(node, peers)
  return false if node.failed? || !node.active?
  return false if !node.has_peers? && peers.refresh_count > 1
  true
end