Skip to content

Commit

Permalink
[GROW-3598] make initialize to loop through replica nodes per cluster…
Browse files Browse the repository at this point in the history
… slots row (#17)
  • Loading branch information
zach-iee authored Sep 14, 2023
1 parent 16f87bf commit d21f2bf
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,25 +1561,25 @@ def initialize(self):
# add this node to the nodes cache
tmp_nodes_cache[target_node.name] = target_node

target_replica_nodes = []
for replica_node in slot[3:]:
host = str_if_bytes(replica_node[0])
port = int(replica_node[1])
host, port = self.remap_host_port(host, port)

target_replica_node = self._get_or_create_cluster_node(
host, port, REPLICA, tmp_nodes_cache
)
target_replica_nodes.append(target_replica_node)
# add this node to the nodes cache
tmp_nodes_cache[target_replica_node.name] = target_replica_node

for i in range(int(slot[0]), int(slot[1]) + 1):
if i not in tmp_slots:
tmp_slots[i] = []
tmp_slots[i].append(target_node)
replica_nodes = [slot[j] for j in range(3, len(slot))]

for replica_node in replica_nodes:
host = str_if_bytes(replica_node[0])
port = replica_node[1]
host, port = self.remap_host_port(host, port)

target_replica_node = self._get_or_create_cluster_node(
host, port, REPLICA, tmp_nodes_cache
)
for target_replica_node in target_replica_nodes:
tmp_slots[i].append(target_replica_node)
# add this node to the nodes cache
tmp_nodes_cache[
target_replica_node.name
] = target_replica_node
else:
# Validate that 2 nodes want to use the same slot cache
# setup
Expand Down

0 comments on commit d21f2bf

Please sign in to comment.