diff options
author | Brennan <31714723+BCathcart@users.noreply.github.com> | 2022-11-01 22:26:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-01 19:26:44 -0700 |
commit | 47c493e070c8ac59ccc34d694700bca8ec517fbc (patch) | |
tree | 3badf9ecdb5b62ceece2e317a90cf2d472559aa5 /tests/support | |
parent | 4a8a62505134094f8de0ca293da932c3d009df15 (diff) | |
download | redis-47c493e070c8ac59ccc34d694700bca8ec517fbc.tar.gz |
Re-design cluster link send buffer to improve memory management (#11343)
Re-design cluster link send queue to improve memory management
Diffstat (limited to 'tests/support')
-rw-r--r-- | tests/support/cluster_util.tcl (renamed from tests/support/cluster_helper.tcl) | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/support/cluster_helper.tcl b/tests/support/cluster_util.tcl index 644eefdae..8a58a4fa9 100644 --- a/tests/support/cluster_helper.tcl +++ b/tests/support/cluster_util.tcl @@ -1,5 +1,4 @@ -# Helper functions specifically for setting up and configuring redis -# clusters. +# Cluster helper functions # Check if cluster configuration is consistent. proc cluster_config_consistent {} { @@ -113,3 +112,41 @@ proc start_cluster {masters replicas options code {slot_allocator continuous_slo start_multiple_servers $node_count $options $code set ::singledb $old_singledb } + +# Test node for flag. +proc cluster_has_flag {node flag} { + expr {[lsearch -exact [dict get $node flags] $flag] != -1} +} + +# Returns the parsed "myself" node entry as a dictionary. +proc cluster_get_myself id { + set nodes [get_cluster_nodes $id] + foreach n $nodes { + if {[cluster_has_flag $n myself]} {return $n} + } + return {} +} + +# Returns a parsed CLUSTER NODES output as a list of dictionaries. +proc get_cluster_nodes id { + set lines [split [R $id cluster nodes] "\r\n"] + set nodes {} + foreach l $lines { + set l [string trim $l] + if {$l eq {}} continue + set args [split $l] + set node [dict create \ + id [lindex $args 0] \ + addr [lindex $args 1] \ + flags [split [lindex $args 2] ,] \ + slaveof [lindex $args 3] \ + ping_sent [lindex $args 4] \ + pong_recv [lindex $args 5] \ + config_epoch [lindex $args 6] \ + linkstate [lindex $args 7] \ + slots [lrange $args 8 end] \ + ] + lappend nodes $node + } + return $nodes +} |