From a68c9ba97eb8ea7b475df354fc505ca4634a8e0a Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 17 Jan 2014 12:06:06 +0100 Subject: [PATCH] Cluster: redis-trib shows what a slave replicates + fixes. Also the :replicates info field in the node object is now correctly populated. This also fixes the :replicas field computation. --- src/redis-trib.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/redis-trib.rb b/src/redis-trib.rb index 5d266ef0..462dad32 100755 --- a/src/redis-trib.rb +++ b/src/redis-trib.rb @@ -119,17 +119,19 @@ class ClusterNode nodes.each{|n| # name addr flags role ping_sent ping_recv link_status slots split = n.split - name,addr,flags,role,ping_sent,ping_recv,config_epoch,link_status = split[0..6] + name,addr,flags,master_id,ping_sent,ping_recv,config_epoch,link_status = split[0..6] slots = split[8..-1] info = { :name => name, :addr => addr, :flags => flags.split(","), - :role => role, + :replicate => master_id, :ping_sent => ping_sent.to_i, :ping_recv => ping_recv.to_i, :link_status => link_status } + info[:replicate] = false if master_id == "-" + if info[:flags].index("myself") @info = @info.merge(info) @info[:slots] = {} @@ -238,12 +240,16 @@ class ClusterNode role = self.has_flag?("master") ? "M" : "S" if self.info[:replicate] and @dirty - "S: #{self.info[:name]} #{self.to_s}" + is = "S: #{self.info[:name]} #{self.to_s}" else - "#{role}: #{self.info[:name]} #{self.to_s}\n"+ + is = "#{role}: #{self.info[:name]} #{self.to_s}\n"+ " slots:#{slots} (#{self.slots.length} slots) "+ "#{(self.info[:flags]-["myself"]).join(",")}" end + if self.info[:replicate] + is += "\n replicates #{info[:replicate]}" + end + is end # Return a single string representing nodes and associated slots. -- GitLab