diff options
author | Harkrishn Patro <30795839+hpatro@users.noreply.github.com> | 2022-01-03 01:54:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-02 16:54:47 -0800 |
commit | 9f8885760b53e6d3952b9c9b41f9e6c48dfa6cec (patch) | |
tree | 770dfdbff19a1a2a1c71a642ebd844d592ef3d26 /tests/cluster/cluster.tcl | |
parent | b8ba942ac2aabf51fd96134d9fa21b47d3baff4a (diff) | |
download | redis-9f8885760b53e6d3952b9c9b41f9e6c48dfa6cec.tar.gz |
Sharded pubsub implementation (#8621)
This commit implements a sharded pubsub implementation based off of shard channels.
Co-authored-by: Harkrishn Patro <harkrisp@amazon.com>
Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
Diffstat (limited to 'tests/cluster/cluster.tcl')
-rw-r--r-- | tests/cluster/cluster.tcl | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/cluster/cluster.tcl b/tests/cluster/cluster.tcl index 7b7ce5343..31e0c3667 100644 --- a/tests/cluster/cluster.tcl +++ b/tests/cluster/cluster.tcl @@ -66,7 +66,7 @@ proc s {n field} { get_info_field [R $n info] $field } -# Assuming nodes are reest, this function performs slots allocation. +# Assuming nodes are reset, this function performs slots allocation. # Only the first 'n' nodes are used. proc cluster_allocate_slots {n} { set slot 16383 @@ -129,6 +129,32 @@ proc create_cluster {masters slaves} { set ::cluster_replica_nodes $slaves } +proc cluster_allocate_with_continuous_slots {n} { + set slot 16383 + set avg [expr ($slot+1) / $n] + while {$slot >= 0} { + set node [expr $slot/$avg >= $n ? $n-1 : $slot/$avg] + lappend slots_$node $slot + incr slot -1 + } + for {set j 0} {$j < $n} {incr j} { + R $j cluster addslots {*}[set slots_${j}] + } +} + +# Create a cluster composed of the specified number of masters and slaves with continuous slots. +proc cluster_create_with_continuous_slots {masters slaves} { + cluster_allocate_with_continuous_slots $masters + if {$slaves} { + cluster_allocate_slaves $masters $slaves + } + assert_cluster_state ok + + set ::cluster_master_nodes $masters + set ::cluster_replica_nodes $slaves +} + + # Set the cluster node-timeout to all the reachalbe nodes. proc set_cluster_node_timeout {to} { foreach_redis_id id { @@ -243,4 +269,4 @@ proc get_link_from_peer {this_instance_id peer_nodename} { } } return {} -} +}
\ No newline at end of file |