lib/aerospike/cluster/cluster.rb in aerospike-2.1.1 vs lib/aerospike/cluster/cluster.rb in aerospike-2.2.0

- old
+ new

@@ -33,20 +33,21 @@ @cluster_seeds = hosts @fail_if_not_connected = policy.fail_if_not_connected @connection_queue_size = policy.connection_queue_size @connection_timeout = policy.timeout @tend_interval = policy.tend_interval + @cluster_name = policy.cluster_name @aliases = {} @cluster_nodes = [] @partition_write_map = {} @node_index = Atomic.new(0) @features = Atomic.new(Set.new) @closed = Atomic.new(true) @mutex = Mutex.new @cluster_config_change_listeners = Atomic.new([]) - @old_node_cound = 0 + @old_node_count = 0 # setup auth info for cluster if policy.requires_authentication @user = policy.user @password = AdminCommand.hash_password(policy.password) @@ -206,10 +207,14 @@ @cluster_config_change_listeners.update do |listeners| listeners.delete(listener) end end + def inspect + "#<Aerospike::Cluster @cluster_nodes=#{@cluster_nodes}>" + end + private def launch_tend_thread @tend_thread = Thread.new do Thread.current.abort_on_exception = false @@ -252,11 +257,12 @@ begin friends = node.refresh refresh_count += 1 friend_list.concat(friends) if friends rescue => e - Aerospike.logger.error("Node `#{node}` refresh failed: #{e.backtrace.join("\n")}") + Aerospike.logger.error("Node `#{node}` refresh failed: #{e}") + Aerospike.logger.error(e.backtrace.join("\n")) end end end # Add nodes in a batch. @@ -277,16 +283,14 @@ if cluster_config_changed update_cluster_features # only log the tend finish IF the number of nodes has been changed. # This prevents spamming the log on every tend interval - if @old_node_cound > nodes.length - Aerospike.logger.info("Tend finished. #{@old_node_cound - nodes.length} nodes have left the cluster. Old node count: #{@old_node_cound}, New node count #{nodes.length} #{nodes}") - else - Aerospike.logger.info("Tend finished. #{nodes.length - @old_node_cound} nodes have joined the cluster. Old node count: #{@old_node_cound}, New node count #{nodes.length} #{nodes}") - end - @old_node_cound = nodes.length + diff = nodes.length - @old_node_count + action = "#{diff.abs} #{diff.abs == 1 ? "node has" : "nodes have"} #{diff > 0 ? "joined" : "left"} the cluster." + Aerospike.logger.info("Tend finished. #{action} Old node count: #{@old_node_count}, New node count: #{nodes.length}") + @old_node_count = nodes.length notify_cluster_config_changed end end @@ -360,11 +364,11 @@ list = [] seed_array.each do |seed| begin - seed_node_validator = NodeValidator.new(self, seed, @connection_timeout) + seed_node_validator = NodeValidator.new(self, seed, @connection_timeout, @cluster_name) rescue => e Aerospike.logger.error("Seed #{seed.to_s} failed: #{e.backtrace.join("\n")}") next end @@ -374,10 +378,10 @@ if aliass == seed nv = seed_node_validator else begin - nv = NodeValidator.new(self, aliass, @connection_timeout) + nv = NodeValidator.new(self, aliass, @connection_timeout, @cluster_name) rescue Exection => e Aerospike.logger.error("Seed #{seed.to_s} failed: #{e}") next end end