Module: Aerospike::Cluster::FindNodesToRemove

Defined in:
lib/aerospike/cluster/find_nodes_to_remove.rb

Overview

Calculates which nodes that should be removed from the cluster

Class Method Summary collapse

Class Method Details

.call(cluster, refresh_count) ⇒ Object



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
# File 'lib/aerospike/cluster/find_nodes_to_remove.rb', line 25

def call(cluster, refresh_count)
  node_list = cluster.nodes

  remove_list = []

  node_list.each do |node|
    unless node.active?
      # Inactive nodes must be removed.
      remove_list << node
      next
    end

    if refresh_count.zero? && node.failed?(5) # 5 or more failures counts as failed
      # All node info requests failed and this node had 5 consecutive failures.
      # Remove node.  If no nodes are left, seeds will be tried in next cluster
      # tend iteration.
      remove_list << node
      next
    end

    if node_list.size > 1 && refresh_count >= 1 && !node.referenced?
      # Node is not referenced by other nodes.
      # Check if node responded to info request.
      if node.failed?
        remove_list << node
      else
        # Node is alive, but not referenced by other nodes.  Check if mapped.
        unless cluster.find_node_in_partition_map(node)
          # Node doesn't have any partitions mapped to it.
          # There is no point in keeping it in the cluster.
          remove_list << node
        end
      end
    end
  end

  remove_list
end