From 2e9b297b4a04515c57bead68c8c368972284cfef Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Fri, 9 Aug 2019 19:28:05 +0300 Subject: [PATCH] refactoring --- .../connection/MasterSlaveConnectionManager.java | 16 ++++++++++++---- .../redisson/pubsub/PublishSubscribeService.java | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java b/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java index eada9a4ef..7a085aeb2 100644 --- a/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java +++ b/redisson/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java @@ -556,8 +556,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager { public RFuture connectionWriteOp(NodeSource source, RedisCommand command) { MasterSlaveEntry entry = getEntry(source); if (entry == null) { - RedisNodeNotFoundException ex = new RedisNodeNotFoundException("Node: " + source + " hasn't been discovered yet"); - return RedissonPromise.newFailedFuture(ex); + return createNodeNotFoundFuture(source); } // fix for https://github.com/redisson/redisson/issues/1548 if (source.getRedirect() != null @@ -587,8 +586,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager { public RFuture connectionReadOp(NodeSource source, RedisCommand command) { MasterSlaveEntry entry = getEntry(source); if (entry == null) { - RedisNodeNotFoundException ex = new RedisNodeNotFoundException("Node: " + source + " hasn't been discovered yet"); - return RedissonPromise.newFailedFuture(ex); + return createNodeNotFoundFuture(source); } if (source.getRedirect() != null) { @@ -601,6 +599,16 @@ public class MasterSlaveConnectionManager implements ConnectionManager { return entry.connectionReadOp(command); } + protected RFuture createNodeNotFoundFuture(NodeSource source) { + RedisNodeNotFoundException ex; + if (source.getSlot() != null && source.getAddr() == null && source.getRedisClient() == null) { + ex = new RedisNodeNotFoundException("Node for slot: " + source.getSlot() + " hasn't been discovered yet. Check cluster slots coverage using CLUSTER NODES command"); + } else { + ex = new RedisNodeNotFoundException("Node: " + source + " hasn't been discovered yet."); + } + return RedissonPromise.newFailedFuture(ex); + } + @Override public void releaseWrite(NodeSource source, RedisConnection connection) { MasterSlaveEntry entry = getEntry(source); diff --git a/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java b/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java index 197af4f10..8d20fe027 100644 --- a/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java +++ b/redisson/src/main/java/org/redisson/pubsub/PublishSubscribeService.java @@ -267,7 +267,7 @@ public class PublishSubscribeService { private RFuture nextPubSubConnection(int slot) { MasterSlaveEntry entry = connectionManager.getEntry(slot); if (entry == null) { - RedisNodeNotFoundException ex = new RedisNodeNotFoundException("Node for slot: " + slot + " hasn't been discovered yet"); + RedisNodeNotFoundException ex = new RedisNodeNotFoundException("Node for slot: " + slot + " hasn't been discovered yet. Check cluster slots coverage using CLUSTER NODES command"); return RedissonPromise.newFailedFuture(ex); } return entry.nextPubSubConnection();