lib/aerospike/cluster.rb
# Returns a random node on the cluster
Returns a random node on the cluster
Returns a random node on the cluster
def random_node
      node_array = nodes
      length = node_array.length
      i = 0
      while i < length
        index = (@node_index.update{ |v| v+1 } % node_array.length).abs
        node = node_array[index]
        return node if node.active?
        i = i.succ
      end
      raise Aerospike::Exceptions::InvalidNode
    end
def random_node node_array = nodes length = node_array . length i = 0 while i < length index = ( @node_index . update { | v | v + 1 } % node_array . length ) . abs node = node_array [ index ] return node if node . active? i = i . succ end raise Aerospike :: Exceptions :: InvalidNode end
Returns a random node on the cluster
Returns a random node on the cluster
# Must copy array reference for copy on write semantics to work. # Must handle concurrency with other non-tending threads, so node_index is consistent.