/** * Get the {@link RedisClusterNode}s (master and slave) serving s specific slot. * * @param slot * @return never {@literal null}. */ public Set<RedisClusterNode> getSlotServingNodes(int slot) { Set<RedisClusterNode> slotServingNodes = new LinkedHashSet<>(nodes.size()); for (RedisClusterNode node : nodes) { if (node.servesSlot(slot)) { slotServingNodes.add(node); } } return slotServingNodes; }
/** * Get the {@link RedisClusterNode} that is the current master serving the given key. * * @param key must not be {@literal null}. * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode getKeyServingMasterNode(byte[] key) { Assert.notNull(key, "Key for node lookup must not be null!"); int slot = ClusterSlotHashUtil.calculateSlot(key); for (RedisClusterNode node : nodes) { if (node.isMaster() && node.servesSlot(slot)) { return node; } } throw new ClusterStateFailureException( String.format("Could not find master node serving slot %s for key '%s',", slot, Arrays.toString(key))); }
/** * Get the {@link RedisClusterNode}s (master and slave) serving s specific slot. * * @param slot * @return never {@literal null}. */ public Set<RedisClusterNode> getSlotServingNodes(int slot) { Set<RedisClusterNode> slotServingNodes = new LinkedHashSet<>(nodes.size()); for (RedisClusterNode node : nodes) { if (node.servesSlot(slot)) { slotServingNodes.add(node); } } return slotServingNodes; }
/** * Get the {@link RedisClusterNode}s (master and slave) serving s specific slot. * * @param slot * @return never {@literal null}. */ public Set<RedisClusterNode> getSlotServingNodes(int slot) { Set<RedisClusterNode> slotServingNodes = new LinkedHashSet<>(nodes.size()); for (RedisClusterNode node : nodes) { if (node.servesSlot(slot)) { slotServingNodes.add(node); } } return slotServingNodes; }
/** * Get the {@link RedisClusterNode} that is the current master serving the given key. * * @param key must not be {@literal null}. * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode getKeyServingMasterNode(byte[] key) { Assert.notNull(key, "Key for node lookup must not be null!"); int slot = ClusterSlotHashUtil.calculateSlot(key); for (RedisClusterNode node : nodes) { if (node.isMaster() && node.servesSlot(slot)) { return node; } } throw new ClusterStateFailureException( String.format("Could not find master node serving slot %s for key '%s',", slot, Arrays.toString(key))); }
/** * Get the {@link RedisClusterNode} that is the current master serving the given key. * * @param key must not be {@literal null}. * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode getKeyServingMasterNode(byte[] key) { Assert.notNull(key, "Key for node lookup must not be null!"); int slot = ClusterSlotHashUtil.calculateSlot(key); for (RedisClusterNode node : nodes) { if (node.isMaster() && node.servesSlot(slot)) { return node; } } throw new ClusterStateFailureException( String.format("Could not find master node serving slot %s for key '%s',", slot, Arrays.toString(key))); }