diff --git a/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java b/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java index 16904068d..a08d2c806 100644 --- a/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java +++ b/redisson/src/main/java/org/redisson/connection/MasterSlaveEntry.java @@ -115,8 +115,6 @@ public class MasterSlaveEntry { } private void removeSlaveEntry(ClientConnectionsEntry entry) { - slaveConnectionPool.removeEntry(entry); - slavePubSubConnectionPool.removeEntry(entry); client2Entry.remove(entry.getClient()); if (config.getSubscriptionMode() == SubscriptionMode.SLAVE) { @@ -125,12 +123,7 @@ public class MasterSlaveEntry { } private void addSlaveEntry(ClientConnectionsEntry entry) { - if (client2Entry.get(entry.getClient()) != null) { - return; - } - slaveConnectionPool.addEntry(entry); - slavePubSubConnectionPool.addEntry(entry); - client2Entry.put(entry.getClient(), entry); + client2Entry.putIfAbsent(entry.getClient(), entry); } private boolean hasNoSlaves() { diff --git a/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java b/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java index 75127c8e2..025f54e26 100644 --- a/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java +++ b/redisson/src/main/java/org/redisson/connection/pool/ConnectionPool.java @@ -29,11 +29,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.net.InetSocketAddress; +import java.util.Collection; import java.util.LinkedList; import java.util.List; -import java.util.Queue; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentLinkedQueue; /** * Base connection pool class @@ -46,8 +45,6 @@ abstract class ConnectionPool { private final Logger log = LoggerFactory.getLogger(getClass()); - final Queue entries = new ConcurrentLinkedQueue<>(); - final ConnectionManager connectionManager; final MasterSlaveServersConfig config; @@ -60,17 +57,10 @@ abstract class ConnectionPool { this.connectionManager = connectionManager; } - public final void addEntry(ClientConnectionsEntry entry) { - entries.add(entry); - } - - public final void removeEntry(ClientConnectionsEntry entry) { - entries.remove(entry); - } - protected abstract ConnectionsHolder getConnectionHolder(ClientConnectionsEntry entry, boolean trackChanges); public CompletableFuture get(RedisCommand command, boolean trackChanges) { + Collection entries = masterSlaveEntry.getAllEntries(); List entriesCopy = new LinkedList<>(entries); entriesCopy.removeIf(n -> n.isFreezed() || !isHealthy(n)); if (!entriesCopy.isEmpty()) {