From 230d7baa21e2edcbc3910cd1e8ca88f0944e72a0 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 22 Jan 2021 13:50:00 +0100 Subject: [PATCH] Introduce template method to supply a custom ClusterTopologyRefresh implementation #1598 --- .../core/cluster/RedisClusterClient.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java b/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java index 772242a331..e67f61cd1a 100644 --- a/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java +++ b/src/main/java/io/lettuce/core/cluster/RedisClusterClient.java @@ -141,8 +141,7 @@ public class RedisClusterClient extends AbstractRedisClient { private static final InternalLogger logger = InternalLoggerFactory.getInstance(RedisClusterClient.class); - private final ClusterTopologyRefresh refresh = ClusterTopologyRefresh.create(new NodeConnectionFactoryImpl(), - getResources()); + private final ClusterTopologyRefresh refresh; private final ClusterTopologyRefreshScheduler topologyRefreshScheduler = new ClusterTopologyRefreshScheduler( this::getClusterClientOptions, this::getPartitions, this::refreshPartitionsAsync, getResources()); @@ -158,7 +157,8 @@ protected RedisClusterClient() { super(null); - initialUris = Collections.emptyList(); + this.initialUris = Collections.emptyList(); + this.refresh = createTopologyRefresh(); } /** @@ -178,6 +178,7 @@ protected RedisClusterClient(ClientResources clientResources, Iterable assertSameOptions(redisURIs); this.initialUris = Collections.unmodifiableList(LettuceLists.newList(redisURIs)); + this.refresh = createTopologyRefresh(); setDefaultTimeout(getFirstUri().getTimeout()); setOptions(ClusterClientOptions.create()); @@ -1089,6 +1090,16 @@ protected void forEachCloseable(Predicate