From 7b2c1895a928ae03aeceb844bfdd6b49a5271b02 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Fri, 31 May 2024 08:19:14 +0300 Subject: [PATCH] Revert "Fixed - Cluster failover handling #5857" This reverts commit c86af4ec18a99caa8fcc3ca9f71f870445504519. --- .../cluster/ClusterConnectionManager.java | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java index 3a26eefa3..c53ceac61 100644 --- a/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java +++ b/redisson/src/main/java/org/redisson/cluster/ClusterConnectionManager.java @@ -338,8 +338,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { addEntry(slot, entry); lastPartitions.put(slot, partition); } - if (partition.getSlotsAmount() > 0 - && partition.getMasterAddress() != null) { + if (partition.getSlotsAmount() > 0) { lastUri2Partition.put(partition.getMasterAddress(), partition); } @@ -499,9 +498,6 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { private CompletableFuture checkSlaveNodesChange(Collection newPartitions) { List> futures = new ArrayList<>(); for (ClusterPartition newPart : newPartitions) { - if (newPart.getMasterAddress() == null) { - continue; - } ClusterPartition currentPart = lastUri2Partition.get(newPart.getMasterAddress()); if (currentPart == null) { continue; @@ -634,8 +630,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { List> futures = new ArrayList<>(); for (ClusterPartition newPart : newPartitions) { - if (newPart.getSlotsAmount() == 0 - || newPart.getMasterAddress() == null) { + if (newPart.getSlotsAmount() == 0) { continue; } @@ -698,7 +693,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { for (Integer removedSlot : removedSlots) { ClusterPartition p = lastPartitions.remove(removedSlot); - if (p != null && p.getMasterAddress() != null) { + if (p != null) { lastUri2Partition.remove(p.getMasterAddress()); } } @@ -713,7 +708,6 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { Integer addedSlots = 0; for (ClusterPartition clusterPartition : newPartitions) { MasterSlaveEntry entry = getEntry(clusterPartition.getMasterAddress()); - boolean hasNewSlots = false; for (Integer slot : clusterPartition.getSlots()) { if (lastPartitions.containsKey(slot)) { continue; @@ -722,19 +716,16 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { if (entry != null) { addEntry(slot, entry); lastPartitions.put(slot, clusterPartition); + lastUri2Partition.put(clusterPartition.getMasterAddress(), clusterPartition); addedSlots++; - hasNewSlots = true; } } - if (hasNewSlots && clusterPartition.getMasterAddress() != null) { - lastUri2Partition.put(clusterPartition.getMasterAddress(), clusterPartition); - } } if (addedSlots > 0) { log.info("{} slots found to add", addedSlots); } } - + private void checkSlotsMigration(Collection newPartitions) { Collection clusterLastPartitions = getLastPartitions(); @@ -760,7 +751,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { lastPartitions.put(slot, currentPartition); changedSlots.add(slot); }); - if (!addedSlots.isEmpty() && currentPartition.getMasterAddress() != null) { + if (!addedSlots.isEmpty()) { lastUri2Partition.put(currentPartition.getMasterAddress(), currentPartition); log.info("{} slots added to {}", addedSlots.cardinality(), currentPartition.getMasterAddress()); } @@ -770,9 +761,7 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager { removedSlots.stream().forEach(slot -> { if (lastPartitions.remove(slot, currentPartition)) { - if (currentPartition.getMasterAddress() != null) { - lastUri2Partition.remove(currentPartition.getMasterAddress()); - } + lastUri2Partition.remove(currentPartition.getMasterAddress()); removeEntry(slot); changedSlots.add(slot); }