mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
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.
This commit is contained in:
parent
b451176734
commit
a68c9ba97e
@ -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
|
|||||||
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user