Commit a68c9ba9 authored by antirez's avatar antirez
Browse files

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.
parent b4511767
...@@ -119,17 +119,19 @@ class ClusterNode ...@@ -119,17 +119,19 @@ class ClusterNode
nodes.each{|n| nodes.each{|n|
# name addr flags role ping_sent ping_recv link_status slots # name addr flags role ping_sent ping_recv link_status slots
split = n.split 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] slots = split[8..-1]
info = { info = {
:name => name, :name => name,
:addr => addr, :addr => addr,
:flags => flags.split(","), :flags => flags.split(","),
:role => role, :replicate => master_id,
:ping_sent => ping_sent.to_i, :ping_sent => ping_sent.to_i,
:ping_recv => ping_recv.to_i, :ping_recv => ping_recv.to_i,
:link_status => link_status :link_status => link_status
} }
info[:replicate] = false if master_id == "-"
if info[:flags].index("myself") if info[:flags].index("myself")
@info = @info.merge(info) @info = @info.merge(info)
@info[:slots] = {} @info[:slots] = {}
...@@ -238,12 +240,16 @@ class ClusterNode ...@@ -238,12 +240,16 @@ class ClusterNode
role = self.has_flag?("master") ? "M" : "S" role = self.has_flag?("master") ? "M" : "S"
if self.info[:replicate] and @dirty if self.info[:replicate] and @dirty
"S: #{self.info[:name]} #{self.to_s}" is = "S: #{self.info[:name]} #{self.to_s}"
else else
"#{role}: #{self.info[:name]} #{self.to_s}\n"+ is = "#{role}: #{self.info[:name]} #{self.to_s}\n"+
" slots:#{slots} (#{self.slots.length} slots) "+ " slots:#{slots} (#{self.slots.length} slots) "+
"#{(self.info[:flags]-["myself"]).join(",")}" "#{(self.info[:flags]-["myself"]).join(",")}"
end end
if self.info[:replicate]
is += "\n replicates #{info[:replicate]}"
end
is
end end
# Return a single string representing nodes and associated slots. # Return a single string representing nodes and associated slots.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment