diff --git a/src/main/java/io/lettuce/core/cluster/PartitionAccessor.java b/src/main/java/io/lettuce/core/cluster/PartitionAccessor.java index 4fe5f29bbe..6fe05da97c 100644 --- a/src/main/java/io/lettuce/core/cluster/PartitionAccessor.java +++ b/src/main/java/io/lettuce/core/cluster/PartitionAccessor.java @@ -39,12 +39,12 @@ List getMasters() { return get(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.MASTER)); } - List getSlaves() { + List getReplicas() { return get(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); } - List getSlaves(RedisClusterNode master) { + List getReplicas(RedisClusterNode master) { return get(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE) && master.getNodeId().equals(redisClusterNode.getSlaveOf())); } diff --git a/src/main/java/io/lettuce/core/cluster/ReadOnlyCommands.java b/src/main/java/io/lettuce/core/cluster/ReadOnlyCommands.java index eec26f6fe3..bbd7c57034 100644 --- a/src/main/java/io/lettuce/core/cluster/ReadOnlyCommands.java +++ b/src/main/java/io/lettuce/core/cluster/ReadOnlyCommands.java @@ -62,7 +62,7 @@ enum CommandName { SUNION, TIME, TTL, TYPE, ZCARD, ZCOUNT, ZLEXCOUNT, ZRANGE, // ZRANGEBYLEX, ZRANGEBYSCORE, ZRANK, ZREVRANGE, ZREVRANGEBYLEX, ZREVRANGEBYSCORE, ZREVRANK, ZSCAN, ZSCORE, // - // Pub/Sub commands are no key-space commands so they are safe to execute on slave nodes + // Pub/Sub commands are no key-space commands so they are safe to execute on replica nodes PUBLISH, PUBSUB, PSUBSCRIBE, PUNSUBSCRIBE, SUBSCRIBE, UNSUBSCRIBE } } diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java index 61365639f9..0c3a6d6ccb 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java @@ -287,7 +287,7 @@ public interface NodeSelectionServerAsyncCommands { AsyncExecutions save(); /** - * Make the server a slave of another instance, or promote it as master. + * Make the server a replica of another instance, or promote it as master. * * @param host the host type: string * @param port the port type: string diff --git a/src/main/java/io/lettuce/core/cluster/api/async/RedisAdvancedClusterAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/RedisAdvancedClusterAsyncCommands.java index 6b5905ea64..dd70d9f22b 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/RedisAdvancedClusterAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/RedisAdvancedClusterAsyncCommands.java @@ -36,8 +36,7 @@ * @author Mark Paluch * @since 4.0 */ -public interface RedisAdvancedClusterAsyncCommands - extends RedisClusterAsyncCommands { +public interface RedisAdvancedClusterAsyncCommands extends RedisClusterAsyncCommands { /** * Retrieve a connection to the specified cluster node using the nodeId. Host and port are looked up in the node list. @@ -77,23 +76,49 @@ default AsyncNodeSelection masters() { } /** - * Select all slaves. + * Select all replicas. * - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas()} */ + @Deprecated default AsyncNodeSelection slaves() { return readonly(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); } /** - * Select all slaves. + * Select all replicas. * * @param predicate Predicate to filter nodes - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated use {@link #replicas(Predicate)} */ + @Deprecated default AsyncNodeSelection slaves(Predicate predicate) { - return readonly( - redisClusterNode -> predicate.test(redisClusterNode) && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + return readonly(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + } + + /** + * Select all replicas. + * + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default AsyncNodeSelection replicas() { + return readonly(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); + } + + /** + * Select all replicas. + * + * @param predicate Predicate to filter nodes + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default AsyncNodeSelection replicas(Predicate predicate) { + return readonly(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); } /** @@ -106,8 +131,8 @@ default AsyncNodeSelection all() { } /** - * Select slave nodes by a predicate and keeps a static selection. Slave connections operate in {@literal READONLY} mode. - * The set of nodes within the {@link NodeSelectionSupport} does not change when the cluster view changes. + * Select replica nodes by a predicate and keeps a static selection. Replica connections operate in {@literal READONLY} + * mode. The set of nodes within the {@link NodeSelectionSupport} does not change when the cluster view changes. * * @param predicate Predicate to filter nodes * @return API with asynchronous executed commands on a selection of cluster nodes matching {@code predicate} @@ -152,7 +177,8 @@ default AsyncNodeSelection all() { RedisFuture unlink(K... keys); /** - * Determine how many keys exist with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes. + * Determine how many keys exist with pipelining. Cross-slot keys will result in multiple calls to the particular cluster + * nodes. * * @param keys the keys * @return Long integer-reply specifically: Number of existing keys diff --git a/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java index 9a8ce99738..b1dffd5123 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/RedisClusterAsyncCommands.java @@ -166,12 +166,12 @@ public interface RedisClusterAsyncCommands extends BaseRedisAsyncCommands< RedisFuture clusterNodes(); /** - * List slaves for a certain node identified by its {@code nodeId}. Can be parsed using + * List replicas for a certain node identified by its {@code nodeId}. Can be parsed using * {@link io.lettuce.core.cluster.models.partitions.ClusterPartitionParser#parse} * * @param nodeId node id of the master node - * @return List<String> array-reply list of slaves. The command returns data in the same format as - * {@link #clusterNodes()} but one line per slave. + * @return List<String> array-reply list of replicas. The command returns data in the same format as + * {@link #clusterNodes()} but one line per replica. */ RedisFuture> clusterSlaves(String nodeId); @@ -247,7 +247,7 @@ public interface RedisClusterAsyncCommands extends BaseRedisAsyncCommands< RedisFuture asking(); /** - * Turn this node into a slave of the node with the id {@code nodeId}. + * Turn this node into a replica of the node with the id {@code nodeId}. * * @param nodeId master node id * @return String simple-string-reply @@ -255,7 +255,7 @@ public interface RedisClusterAsyncCommands extends BaseRedisAsyncCommands< RedisFuture clusterReplicate(String nodeId); /** - * Failover a cluster node. Turns the currently connected node into a master and the master into its slave. + * Failover a cluster node. Turns the currently connected node into a master and the master into its replica. * * @param force do not coordinate with master if {@literal true} * @return String simple-string-reply @@ -267,11 +267,11 @@ public interface RedisClusterAsyncCommands extends BaseRedisAsyncCommands< *
    *
  • All other nodes are forgotten
  • *
  • All the assigned / open slots are released
  • - *
  • If the node is a slave, it turns into a master
  • + *
  • If the node is a replica, it turns into a master
  • *
  • Only for hard reset: a new Node ID is generated
  • *
  • Only for hard reset: currentEpoch and configEpoch are set to 0
  • *
  • The new configuration is saved and the cluster state updated
  • - *
  • If the node was a slave, the whole data set is flushed away
  • + *
  • If the node was a replica, the whole data set is flushed away
  • *
* * @param hard {@literal true} for hard reset. Generates a new nodeId and currentEpoch/configEpoch are set to 0 @@ -287,7 +287,7 @@ public interface RedisClusterAsyncCommands extends BaseRedisAsyncCommands< RedisFuture clusterFlushslots(); /** - * Tells a Redis cluster slave node that the client is ok reading possibly stale data and is not interested in running write + * Tells a Redis cluster replica node that the client is ok reading possibly stale data and is not interested in running write * queries. * * @return String simple-string-reply diff --git a/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java b/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java index 4357f42624..f742c0aabb 100644 --- a/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/reactive/RedisClusterReactiveCommands.java @@ -167,12 +167,12 @@ public interface RedisClusterReactiveCommands extends BaseRedisReactiveCom Mono clusterNodes(); /** - * List slaves for a certain node identified by its {@code nodeId}. Can be parsed using + * List replicas for a certain node identified by its {@code nodeId}. Can be parsed using * {@link io.lettuce.core.cluster.models.partitions.ClusterPartitionParser#parse} * * @param nodeId node id of the master node - * @return List<String> array-reply list of slaves. The command returns data in the same format as - * {@link #clusterNodes()} but one line per slave. + * @return List<String> array-reply list of replicas. The command returns data in the same format as + * {@link #clusterNodes()} but one line per replica. */ Flux clusterSlaves(String nodeId); @@ -248,7 +248,7 @@ public interface RedisClusterReactiveCommands extends BaseRedisReactiveCom Mono asking(); /** - * Turn this node into a slave of the node with the id {@code nodeId}. + * Turn this node into a replica of the node with the id {@code nodeId}. * * @param nodeId master node id * @return String simple-string-reply @@ -256,7 +256,7 @@ public interface RedisClusterReactiveCommands extends BaseRedisReactiveCom Mono clusterReplicate(String nodeId); /** - * Failover a cluster node. Turns the currently connected node into a master and the master into its slave. + * Failover a cluster node. Turns the currently connected node into a master and the master into its replica. * * @param force do not coordinate with master if {@literal true} * @return String simple-string-reply @@ -268,11 +268,11 @@ public interface RedisClusterReactiveCommands extends BaseRedisReactiveCom *
    *
  • All other nodes are forgotten
  • *
  • All the assigned / open slots are released
  • - *
  • If the node is a slave, it turns into a master
  • + *
  • If the node is a replica, it turns into a master
  • *
  • Only for hard reset: a new Node ID is generated
  • *
  • Only for hard reset: currentEpoch and configEpoch are set to 0
  • *
  • The new configuration is saved and the cluster state updated
  • - *
  • If the node was a slave, the whole data set is flushed away
  • + *
  • If the node was a replica, the whole data set is flushed away
  • *
* * @param hard {@literal true} for hard reset. Generates a new nodeId and currentEpoch/configEpoch are set to 0 @@ -288,7 +288,7 @@ public interface RedisClusterReactiveCommands extends BaseRedisReactiveCom Mono clusterFlushslots(); /** - * Tells a Redis cluster slave node that the client is ok reading possibly stale data and is not interested in running write + * Tells a Redis cluster replica node that the client is ok reading possibly stale data and is not interested in running write * queries. * * @return String simple-string-reply diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java index 34c03ab1bc..7a7017dac6 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java @@ -287,7 +287,7 @@ public interface NodeSelectionServerCommands { Executions save(); /** - * Make the server a slave of another instance, or promote it as master. + * Make the server a replica of another instance, or promote it as master. * * @param host the host type: string * @param port the port type: string diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/RedisAdvancedClusterCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/RedisAdvancedClusterCommands.java index a7842f4545..e7bebd2ae8 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/RedisAdvancedClusterCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/RedisAdvancedClusterCommands.java @@ -74,23 +74,49 @@ default NodeSelection masters() { } /** - * Select all slaves. + * Select all replicas. * - * @return API with synchronous executed commands on a selection of slave cluster nodes. + * @return API with synchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas()} */ + @Deprecated default NodeSelection slaves() { return readonly(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); } /** - * Select all slaves. + * Select all replicas. * * @param predicate Predicate to filter nodes - * @return API with synchronous executed commands on a selection of slave cluster nodes. + * @return API with synchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas(Predicate)} */ + @Deprecated default NodeSelection slaves(Predicate predicate) { - return readonly( - redisClusterNode -> predicate.test(redisClusterNode) && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + return readonly(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + } + + /** + * Select all replicas. + * + * @return API with synchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default NodeSelection replicas() { + return readonly(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); + } + + /** + * Select all replicas. + * + * @param predicate Predicate to filter nodes + * @return API with synchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default NodeSelection replicas(Predicate predicate) { + return readonly(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); } /** @@ -103,8 +129,8 @@ default NodeSelection all() { } /** - * Select slave nodes by a predicate and keeps a static selection. Slave connections operate in {@literal READONLY} mode. - * The set of nodes within the {@link NodeSelectionSupport} does not change when the cluster view changes. + * Select replica nodes by a predicate and keeps a static selection. Replica connections operate in {@literal READONLY} + * mode. The set of nodes within the {@link NodeSelectionSupport} does not change when the cluster view changes. * * @param predicate Predicate to filter nodes * @return API with synchronous executed commands on a selection of cluster nodes matching {@code predicate} @@ -149,7 +175,8 @@ default NodeSelection all() { Long unlink(K... keys); /** - * Determine how many keys exist with pipelining. Cross-slot keys will result in multiple calls to the particular cluster nodes. + * Determine how many keys exist with pipelining. Cross-slot keys will result in multiple calls to the particular cluster + * nodes. * * @param keys the keys * @return Long integer-reply specifically: Number of existing keys diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java index 6a48668804..cebceaedd7 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/RedisClusterCommands.java @@ -163,12 +163,12 @@ public interface RedisClusterCommands extends BaseRedisCommands, Red String clusterNodes(); /** - * List slaves for a certain node identified by its {@code nodeId}. Can be parsed using + * List replicas for a certain node identified by its {@code nodeId}. Can be parsed using * {@link io.lettuce.core.cluster.models.partitions.ClusterPartitionParser#parse} * * @param nodeId node id of the master node - * @return List<String> array-reply list of slaves. The command returns data in the same format as - * {@link #clusterNodes()} but one line per slave. + * @return List<String> array-reply list of replicas. The command returns data in the same format as + * {@link #clusterNodes()} but one line per replica. */ List clusterSlaves(String nodeId); @@ -244,7 +244,7 @@ public interface RedisClusterCommands extends BaseRedisCommands, Red String asking(); /** - * Turn this node into a slave of the node with the id {@code nodeId}. + * Turn this node into a replica of the node with the id {@code nodeId}. * * @param nodeId master node id * @return String simple-string-reply @@ -252,7 +252,7 @@ public interface RedisClusterCommands extends BaseRedisCommands, Red String clusterReplicate(String nodeId); /** - * Failover a cluster node. Turns the currently connected node into a master and the master into its slave. + * Failover a cluster node. Turns the currently connected node into a master and the master into its replica. * * @param force do not coordinate with master if {@literal true} * @return String simple-string-reply @@ -264,11 +264,11 @@ public interface RedisClusterCommands extends BaseRedisCommands, Red *
    *
  • All other nodes are forgotten
  • *
  • All the assigned / open slots are released
  • - *
  • If the node is a slave, it turns into a master
  • + *
  • If the node is a replica, it turns into a master
  • *
  • Only for hard reset: a new Node ID is generated
  • *
  • Only for hard reset: currentEpoch and configEpoch are set to 0
  • *
  • The new configuration is saved and the cluster state updated
  • - *
  • If the node was a slave, the whole data set is flushed away
  • + *
  • If the node was a replica, the whole data set is flushed away
  • *
* * @param hard {@literal true} for hard reset. Generates a new nodeId and currentEpoch/configEpoch are set to 0 @@ -284,7 +284,7 @@ public interface RedisClusterCommands extends BaseRedisCommands, Red String clusterFlushslots(); /** - * Tells a Redis cluster slave node that the client is ok reading possibly stale data and is not interested in running write + * Tells a Redis cluster replica node that the client is ok reading possibly stale data and is not interested in running write * queries. * * @return String simple-string-reply diff --git a/src/main/java/io/lettuce/core/cluster/models/partitions/ClusterPartitionParser.java b/src/main/java/io/lettuce/core/cluster/models/partitions/ClusterPartitionParser.java index 3152ff046a..f174e35f60 100644 --- a/src/main/java/io/lettuce/core/cluster/models/partitions/ClusterPartitionParser.java +++ b/src/main/java/io/lettuce/core/cluster/models/partitions/ClusterPartitionParser.java @@ -49,6 +49,7 @@ public class ClusterPartitionParser { map.put("myself", RedisClusterNode.NodeFlag.MYSELF); map.put("master", RedisClusterNode.NodeFlag.MASTER); map.put("slave", RedisClusterNode.NodeFlag.SLAVE); + map.put("replica", RedisClusterNode.NodeFlag.REPLICA); map.put("fail?", RedisClusterNode.NodeFlag.EVENTUAL_FAIL); map.put("fail", RedisClusterNode.NodeFlag.FAIL); map.put("handshake", RedisClusterNode.NodeFlag.HANDSHAKE); @@ -74,8 +75,7 @@ public static Partitions parse(String nodes) { try { List mappedNodes = TOKEN_PATTERN.splitAsStream(nodes).filter(s -> !s.isEmpty()) - .map(ClusterPartitionParser::parseNode) - .collect(Collectors.toList()); + .map(ClusterPartitionParser::parseNode).collect(Collectors.toList()); result.addAll(mappedNodes); } catch (Exception e) { throw new RedisException("Cannot parse " + nodes, e); @@ -93,7 +93,7 @@ private static RedisClusterNode parseNode(String nodeInformation) { RedisURI uri = null; String hostAndPortPart = iterator.next(); - if(hostAndPortPart.contains("@")) { + if (hostAndPortPart.contains("@")) { hostAndPortPart = hostAndPortPart.substring(0, hostAndPortPart.indexOf('@')); } @@ -108,8 +108,8 @@ private static RedisClusterNode parseNode(String nodeInformation) { Set nodeFlags = readFlags(flagStrings); - String slaveOfString = iterator.next(); // (nodeId or -) - String slaveOf = "-".equals(slaveOfString) ? null : slaveOfString; + String replicaOfString = iterator.next(); // (nodeId or -) + String replicaOf = "-".equals(replicaOfString) ? null : replicaOfString; long pingSentTs = getLongFromIterator(iterator, 0); long pongReceivedTs = getLongFromIterator(iterator, 0); @@ -124,7 +124,7 @@ private static RedisClusterNode parseNode(String nodeInformation) { List slotStrings = LettuceLists.newList(iterator); // slot, from-to [slot->-nodeID] [slot-<-nodeID] List slots = readSlots(slotStrings); - RedisClusterNode partition = new RedisClusterNode(uri, nodeId, connected, slaveOf, pingSentTs, pongReceivedTs, + RedisClusterNode partition = new RedisClusterNode(uri, nodeId, connected, replicaOf, pingSentTs, pongReceivedTs, configEpoch, slots, nodeFlags); return partition; @@ -139,6 +139,11 @@ private static Set readFlags(List flagStrings flags.add(FLAG_MAPPING.get(flagString)); } } + + if (flags.contains(RedisClusterNode.NodeFlag.SLAVE)) { + flags.add(RedisClusterNode.NodeFlag.REPLICA); + } + return Collections.unmodifiableSet(flags); } diff --git a/src/main/java/io/lettuce/core/cluster/models/partitions/Partitions.java b/src/main/java/io/lettuce/core/cluster/models/partitions/Partitions.java index ecfdd8643b..03842de8f9 100644 --- a/src/main/java/io/lettuce/core/cluster/models/partitions/Partitions.java +++ b/src/main/java/io/lettuce/core/cluster/models/partitions/Partitions.java @@ -38,7 +38,7 @@ * {@link io.lettuce.core.cluster.models.partitions.RedisClusterNode.NodeFlag#SLAVE} state *
  • Newly added or removed nodes to/from the Redis Cluster
  • *
  • Changes in {@link RedisClusterNode#getSlots()} responsibility
  • - *
  • Changes to the {@link RedisClusterNode#getSlaveOf() slave replication source} (the master of a slave)
  • + *
  • Changes to the {@link RedisClusterNode#getSlaveOf() replication source} (the master of a replica)
  • *
  • Changes to the {@link RedisClusterNode#getUri()} () connection point}
  • * * diff --git a/src/main/java/io/lettuce/core/cluster/models/partitions/RedisClusterNode.java b/src/main/java/io/lettuce/core/cluster/models/partitions/RedisClusterNode.java index a6570c9c39..eaa07f1595 100644 --- a/src/main/java/io/lettuce/core/cluster/models/partitions/RedisClusterNode.java +++ b/src/main/java/io/lettuce/core/cluster/models/partitions/RedisClusterNode.java @@ -26,8 +26,8 @@ /** * Representation of a Redis Cluster node. A {@link RedisClusterNode} is identified by its {@code nodeId}. *

    - * A {@link RedisClusterNode} can be a {@link #getRole() responsible master} or slave. Masters can be responsible for zero to - * {@link io.lettuce.core.cluster.SlotHash#SLOT_COUNT 16384} slots. Each slave refers to exactly one {@link #getSlaveOf() + * A {@link RedisClusterNode} can be a {@link #getRole() responsible master} or replica. Masters can be responsible for zero to + * {@link io.lettuce.core.cluster.SlotHash#SLOT_COUNT 16384} slots. Each replica refers to exactly one {@link #getSlaveOf() * master}. Nodes can have different {@link io.lettuce.core.cluster.models.partitions.RedisClusterNode.NodeFlag flags} assigned. *

    * This class is mutable and not thread-safe if mutated by multiple threads concurrently. @@ -358,6 +358,6 @@ public String toString() { * Redis Cluster node flags. */ public enum NodeFlag { - NOFLAGS, MYSELF, SLAVE, MASTER, EVENTUAL_FAIL, FAIL, HANDSHAKE, NOADDR; + NOFLAGS, MYSELF, SLAVE, REPLICA, MASTER, EVENTUAL_FAIL, FAIL, HANDSHAKE, NOADDR; } } diff --git a/src/main/java/io/lettuce/core/cluster/models/slots/ClusterSlotRange.java b/src/main/java/io/lettuce/core/cluster/models/slots/ClusterSlotRange.java index 132d0c1cfd..05ab3ac770 100644 --- a/src/main/java/io/lettuce/core/cluster/models/slots/ClusterSlotRange.java +++ b/src/main/java/io/lettuce/core/cluster/models/slots/ClusterSlotRange.java @@ -27,7 +27,7 @@ import io.lettuce.core.internal.LettuceAssert; /** - * Represents a range of slots together with its master and slaves. + * Represents a range of slots together with its master and replicas. * * @author Mark Paluch * @since 3.0 @@ -39,7 +39,7 @@ public class ClusterSlotRange implements Serializable { private int to; private RedisClusterNode masterNode; - private List slaveNodes = Collections.emptyList(); + private List replicaNodes = Collections.emptyList(); public ClusterSlotRange() { } @@ -50,17 +50,17 @@ public ClusterSlotRange() { * @param from from slot * @param to to slot * @param masterNode master for the slots, may be {@literal null} - * @param slaveNodes list of slaves must not be {@literal null} but may be empty + * @param replicaNodes list of replicas must not be {@literal null} but may be empty */ - public ClusterSlotRange(int from, int to, RedisClusterNode masterNode, List slaveNodes) { + public ClusterSlotRange(int from, int to, RedisClusterNode masterNode, List replicaNodes) { LettuceAssert.notNull(masterNode, "MasterNode must not be null"); - LettuceAssert.notNull(slaveNodes, "SlaveNodes must not be null"); + LettuceAssert.notNull(replicaNodes, "ReplicaNodes must not be null"); this.from = from; this.to = to; this.masterNode = masterNode; - this.slaveNodes = slaveNodes; + this.replicaNodes = replicaNodes; } private RedisClusterNode toRedisClusterNode(HostAndPort hostAndPort, String slaveOf, Set flags) { @@ -98,12 +98,22 @@ public void setMasterNode(RedisClusterNode masterNode) { this.masterNode = masterNode; } + @Deprecated public List getSlaveNodes() { - return slaveNodes; + return replicaNodes; } + @Deprecated public void setSlaveNodes(List slaveNodes) { - this.slaveNodes = slaveNodes; + this.replicaNodes = slaveNodes; + } + + public List getReplicaNodes() { + return replicaNodes; + } + + public void setReplicaNodes(List replicaNodes) { + this.replicaNodes = replicaNodes; } public void setFrom(int from) { @@ -121,7 +131,7 @@ public String toString() { sb.append(" [from=").append(from); sb.append(", to=").append(to); sb.append(", masterNode=").append(masterNode); - sb.append(", slaveNodes=").append(slaveNodes); + sb.append(", replicaNodes=").append(replicaNodes); sb.append(']'); return sb.toString(); } diff --git a/src/main/java/io/lettuce/core/cluster/pubsub/StatefulRedisClusterPubSubConnection.java b/src/main/java/io/lettuce/core/cluster/pubsub/StatefulRedisClusterPubSubConnection.java index 33da9f24a7..8a6579fbe6 100644 --- a/src/main/java/io/lettuce/core/cluster/pubsub/StatefulRedisClusterPubSubConnection.java +++ b/src/main/java/io/lettuce/core/cluster/pubsub/StatefulRedisClusterPubSubConnection.java @@ -63,7 +63,7 @@ * connection.addListener(…); * * RedisClusterPubSubCommands sync = connection.sync(); - * sync.slaves().commands().psubscribe("__key*__:*"); + * sync.replicas().commands().psubscribe("__key*__:*"); * * * diff --git a/src/main/java/io/lettuce/core/cluster/pubsub/api/async/RedisClusterPubSubAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/pubsub/api/async/RedisClusterPubSubAsyncCommands.java index db29495371..ecc9a10248 100644 --- a/src/main/java/io/lettuce/core/cluster/pubsub/api/async/RedisClusterPubSubAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/pubsub/api/async/RedisClusterPubSubAsyncCommands.java @@ -47,23 +47,49 @@ default PubSubAsyncNodeSelection masters() { } /** - * Select all slaves. + * Select all replicas. * - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas()} */ default PubSubAsyncNodeSelection slaves() { return nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); } /** - * Select all slaves. + * Select all replicas. * * @param predicate Predicate to filter nodes - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas(Predicate)} */ + @Deprecated default PubSubAsyncNodeSelection slaves(Predicate predicate) { - return nodes( - redisClusterNode -> predicate.test(redisClusterNode) && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + return nodes(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + } + + /** + * Select all replicas. + * + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + @Deprecated + default PubSubAsyncNodeSelection replicas() { + return nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); + } + + /** + * Select all replicas. + * + * @param predicate Predicate to filter nodes + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default PubSubAsyncNodeSelection replicas(Predicate predicate) { + return nodes(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); } /** diff --git a/src/main/java/io/lettuce/core/cluster/pubsub/api/reactive/RedisClusterPubSubReactiveCommands.java b/src/main/java/io/lettuce/core/cluster/pubsub/api/reactive/RedisClusterPubSubReactiveCommands.java index cb32be6125..21a4354e24 100644 --- a/src/main/java/io/lettuce/core/cluster/pubsub/api/reactive/RedisClusterPubSubReactiveCommands.java +++ b/src/main/java/io/lettuce/core/cluster/pubsub/api/reactive/RedisClusterPubSubReactiveCommands.java @@ -47,23 +47,49 @@ default PubSubReactiveNodeSelection masters() { } /** - * Select all slaves. + * Select all replicas. * - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas()}. */ + @Deprecated default PubSubReactiveNodeSelection slaves() { return nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); } /** - * Select all slaves. + * Select all replicas. * * @param predicate Predicate to filter nodes - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas()}. */ + @Deprecated default PubSubReactiveNodeSelection slaves(Predicate predicate) { - return nodes( - redisClusterNode -> predicate.test(redisClusterNode) && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + return nodes(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + } + + /** + * Select all replicas. + * + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default PubSubReactiveNodeSelection replicas() { + return nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); + } + + /** + * Select all replicas. + * + * @param predicate Predicate to filter nodes + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default PubSubReactiveNodeSelection replicas(Predicate predicate) { + return nodes(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); } /** diff --git a/src/main/java/io/lettuce/core/cluster/pubsub/api/sync/RedisClusterPubSubCommands.java b/src/main/java/io/lettuce/core/cluster/pubsub/api/sync/RedisClusterPubSubCommands.java index e44fde97f5..92d57d6b63 100644 --- a/src/main/java/io/lettuce/core/cluster/pubsub/api/sync/RedisClusterPubSubCommands.java +++ b/src/main/java/io/lettuce/core/cluster/pubsub/api/sync/RedisClusterPubSubCommands.java @@ -47,23 +47,49 @@ default PubSubNodeSelection masters() { } /** - * Select all slaves. + * Select all replicas. * - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas()} */ + @Deprecated default PubSubNodeSelection slaves() { return nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); } /** - * Select all slaves. + * Select all replicas. * * @param predicate Predicate to filter nodes - * @return API with asynchronous executed commands on a selection of slave cluster nodes. + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @deprecated since 5.2, use {@link #replicas(Predicate)} */ + @Deprecated default PubSubNodeSelection slaves(Predicate predicate) { - return nodes( - redisClusterNode -> predicate.test(redisClusterNode) && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + return nodes(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)); + } + + /** + * Select all replicas. + * + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default PubSubNodeSelection replicas() { + return nodes(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); + } + + /** + * Select all replicas. + * + * @param predicate Predicate to filter nodes + * @return API with asynchronous executed commands on a selection of replica cluster nodes. + * @since 5.2 + */ + default PubSubNodeSelection replicas(Predicate predicate) { + return nodes(redisClusterNode -> predicate.test(redisClusterNode) + && redisClusterNode.is(RedisClusterNode.NodeFlag.REPLICA)); } /** diff --git a/src/main/java/io/lettuce/core/masterslave/AutodiscoveryConnector.java b/src/main/java/io/lettuce/core/masterslave/AutodiscoveryConnector.java index aec7bd4da8..5eb906d746 100644 --- a/src/main/java/io/lettuce/core/masterslave/AutodiscoveryConnector.java +++ b/src/main/java/io/lettuce/core/masterslave/AutodiscoveryConnector.java @@ -35,7 +35,7 @@ import io.lettuce.core.models.role.RedisNodeDescription; /** - * {@link MasterSlaveConnector} to connect unmanaged Redis Master/Slave with auto-discovering master and slave nodes from a + * {@link MasterSlaveConnector} to connect unmanaged Redis Master/Slave with auto-discovering master and replica nodes from a * single {@link RedisURI}. * * @author Mark Paluch diff --git a/src/main/java/io/lettuce/core/masterslave/MasterSlave.java b/src/main/java/io/lettuce/core/masterslave/MasterSlave.java index 1841f9431c..37b794e4ff 100644 --- a/src/main/java/io/lettuce/core/masterslave/MasterSlave.java +++ b/src/main/java/io/lettuce/core/masterslave/MasterSlave.java @@ -60,7 +60,7 @@ * *

      *
    • {@link MasterSlaveTopologyProvider}: Dynamic topology lookup using the {@code INFO REPLICATION} output. Slaves are listed - * as {@code slaveN=...} entries. The initial connection can either point to a master or a slave and the topology provider will + * as {@code slaveN=...} entries. The initial connection can either point to a master or a replica and the topology provider will * discover nodes. The connection needs to be re-established outside of lettuce in a case of Master/Slave failover or topology * changes.
    • *
    • {@link StaticMasterSlaveTopologyProvider}: Topology is defined by the list of {@link RedisURI URIs} and the {@code ROLE} @@ -99,7 +99,7 @@ public class MasterSlave { * {@link RedisCodec codec} to encode/decode keys. *

      * This {@link MasterSlave} performs auto-discovery of nodes using either Redis Sentinel or Master/Slave. A {@link RedisURI} - * can point to either a master or a slave host. + * can point to either a master or a replica host. *

      * * @param redisClient the Redis client. @@ -124,7 +124,7 @@ public static StatefulRedisMasterSlaveConnection connect(RedisClien * supplied {@link RedisCodec codec} to encode/decode keys. *

      * This {@link MasterSlave} performs auto-discovery of nodes using either Redis Sentinel or Master/Slave. A {@link RedisURI} - * can point to either a master or a slave host. + * can point to either a master or a replica host. *

      * * @param redisClient the Redis client. diff --git a/src/main/java/io/lettuce/core/masterslave/MasterSlaveTopologyRefresh.java b/src/main/java/io/lettuce/core/masterslave/MasterSlaveTopologyRefresh.java index 89f27d6512..13e8cf8f22 100644 --- a/src/main/java/io/lettuce/core/masterslave/MasterSlaveTopologyRefresh.java +++ b/src/main/java/io/lettuce/core/masterslave/MasterSlaveTopologyRefresh.java @@ -59,7 +59,7 @@ class MasterSlaveTopologyRefresh { } /** - * Load master slave nodes. Result contains an ordered list of {@link RedisNodeDescription}s. The sort key is the latency. + * Load master replica nodes. Result contains an ordered list of {@link RedisNodeDescription}s. The sort key is the latency. * Nodes with lower latency come first. * * @param seed collection of {@link RedisURI}s diff --git a/src/main/java/io/lettuce/core/sentinel/api/reactive/RedisSentinelReactiveCommands.java b/src/main/java/io/lettuce/core/sentinel/api/reactive/RedisSentinelReactiveCommands.java index 1f48772c19..b57be0d3a6 100644 --- a/src/main/java/io/lettuce/core/sentinel/api/reactive/RedisSentinelReactiveCommands.java +++ b/src/main/java/io/lettuce/core/sentinel/api/reactive/RedisSentinelReactiveCommands.java @@ -58,7 +58,7 @@ public interface RedisSentinelReactiveCommands { Mono> master(K key); /** - * Provides a list of slaves for the master with the specified name. + * Provides a list of replicas for the master with the specified name. * * @param key the key * @return Map<K, V> diff --git a/src/main/java/io/lettuce/core/sentinel/api/sync/RedisSentinelCommands.java b/src/main/java/io/lettuce/core/sentinel/api/sync/RedisSentinelCommands.java index f212190249..4165c49cb2 100644 --- a/src/main/java/io/lettuce/core/sentinel/api/sync/RedisSentinelCommands.java +++ b/src/main/java/io/lettuce/core/sentinel/api/sync/RedisSentinelCommands.java @@ -57,7 +57,7 @@ public interface RedisSentinelCommands { Map master(K key); /** - * Provides a list of slaves for the master with the specified name. + * Provides a list of replicas for the master with the specified name. * * @param key the key * @return List<Map<K, V>> diff --git a/src/main/templates/io/lettuce/core/api/RedisSentinelCommands.java b/src/main/templates/io/lettuce/core/api/RedisSentinelCommands.java index 602a90e966..82f22c8a6f 100644 --- a/src/main/templates/io/lettuce/core/api/RedisSentinelCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisSentinelCommands.java @@ -56,7 +56,7 @@ public interface RedisSentinelCommands { Map master(K key); /** - * Provides a list of slaves for the master with the specified name. + * Provides a list of replicas for the master with the specified name. * * @param key the key * @return List<Map<K, V>> diff --git a/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java index 4b496dc601..e8c3b23c5e 100644 --- a/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/AdvancedClusterReactiveIntegrationTests.java @@ -306,7 +306,7 @@ void shutdown() { } @Test - void readFromSlaves() { + void readFromReplicas() { RedisClusterReactiveCommands connection = commands.getConnection(ClusterTestSettings.host, ClusterTestSettings.port4); diff --git a/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java index ce7c4f56fc..278d3558d9 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterCommandIntegrationTests.java @@ -115,7 +115,7 @@ void testClusterNodesSync() { } @Test - void testClusterSlaves() { + void testClusterReplicas() { sync.set("b", value); RedisFuture replication = async.waitForReplication(1, 5); @@ -178,12 +178,12 @@ void readOnly() throws Exception { assertThat(connect3.readOnly()).isEqualTo("OK"); waitUntilValueIsVisible(key, connect3); - String resultBViewedBySlave = connect3.get("b"); - assertThat(resultBViewedBySlave).isEqualTo(value); + String resultBViewedByReplica = connect3.get("b"); + assertThat(resultBViewedByReplica).isEqualTo(value); connect3.quit(); - resultBViewedBySlave = connect3.get("b"); - assertThat(resultBViewedBySlave).isEqualTo(value); + resultBViewedByReplica = connect3.get("b"); + assertThat(resultBViewedByReplica).isEqualTo(value); } @Test @@ -202,8 +202,8 @@ void readOnlyWithReconnect() throws Exception { connect3.quit(); waitUntilValueIsVisible(key, connect3); - String resultViewedBySlave = connect3.get("b"); - assertThat(resultViewedBySlave).isEqualTo(value); + String resultViewedByReplica = connect3.get("b"); + assertThat(resultViewedByReplica).isEqualTo(value); } @Test diff --git a/src/test/java/io/lettuce/core/cluster/ClusterSetup.java b/src/test/java/io/lettuce/core/cluster/ClusterSetup.java index ccc8600a2e..c3613ea305 100644 --- a/src/test/java/io/lettuce/core/cluster/ClusterSetup.java +++ b/src/test/java/io/lettuce/core/cluster/ClusterSetup.java @@ -90,7 +90,7 @@ public static void setup2Masters(ClusterRule clusterRule) { * * @param clusterRule */ - public static void setupMasterWithSlave(ClusterRule clusterRule) { + public static void setupMasterWithReplica(ClusterRule clusterRule) { clusterRule.clusterReset(); clusterRule.meet(ClusterTestSettings.host, ClusterTestSettings.port5); @@ -134,15 +134,4 @@ private static Stream partitionStream(ClusterRule clusterRule) return clusterRule.getClusterClient().getPartitions().getPartitions().stream(); } - private static boolean is2Masters2Slaves(ClusterRule clusterRule) { - RedisClusterClient clusterClient = clusterRule.getClusterClient(); - - long slaves = clusterClient.getPartitions().stream() - .filter(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.SLAVE)).count(); - long masters = clusterClient.getPartitions().stream() - .filter(redisClusterNode -> redisClusterNode.is(RedisClusterNode.NodeFlag.MASTER)).count(); - - return slaves == 2 && masters == 2; - } - } diff --git a/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java index 676286da91..e1dae91104 100644 --- a/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/NodeSelectionAsyncIntegrationTests.java @@ -237,10 +237,10 @@ void testAsynchronicityOfMultiNodeExecution() { } @Test - void testSlavesReadWrite() { + void testReplicaReadWrite() { AsyncNodeSelection nodes = commands.nodes(redisClusterNode -> redisClusterNode.getFlags().contains( - RedisClusterNode.NodeFlag.SLAVE)); + RedisClusterNode.NodeFlag.REPLICA)); assertThat(nodes.size()).isEqualTo(2); @@ -263,10 +263,10 @@ void testSlavesReadWrite() { } @Test - void testSlavesWithReadOnly() { + void testReplicasWithReadOnly() { - AsyncNodeSelection nodes = commands.slaves(redisClusterNode -> redisClusterNode - .is(RedisClusterNode.NodeFlag.SLAVE)); + AsyncNodeSelection nodes = commands.replicas(redisClusterNode -> redisClusterNode + .is(RedisClusterNode.NodeFlag.REPLICA)); assertThat(nodes.size()).isEqualTo(2); @@ -299,7 +299,7 @@ static void waitForReplication(RedisAdvancedClusterAsyncCommands { AsyncNodeSelection selection = commands - .slaves(redisClusterNode -> redisClusterNode.getUri().getPort() == port); + .replicas(redisClusterNode -> redisClusterNode.getUri().getPort() == port); Wait.untilNotEquals(null, () -> { for (CompletableFuture future : selection.commands().get(key).futures()) { diff --git a/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java index 81494166d9..4e6aa77b02 100644 --- a/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/NodeSelectionSyncIntegrationTests.java @@ -181,7 +181,7 @@ void testAsynchronicityOfMultiNodeExecution() { } @Test - void testSlavesReadWrite() { + void testReplicasReadWrite() { NodeSelection nodes = commands.nodes(redisClusterNode -> redisClusterNode.getFlags().contains( RedisClusterNode.NodeFlag.SLAVE)); diff --git a/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java b/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java index b85d2b2283..24ca354392 100644 --- a/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/ReadFromUnitTests.java @@ -72,7 +72,7 @@ void replica() { } @Test - void slavePreferred() { + void replicaPreferred() { List result = ReadFrom.REPLICA_PREFERRED.select(getNodes()); assertThat(result).hasSize(3).containsExactly(nearest, replica, master); } diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java index 18445a76b6..7a9aaa28de 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterReadFromIntegrationTests.java @@ -81,7 +81,7 @@ void readWriteMasterPreferred() { } @Test - void readWriteSlave() { + void readWriteReplica() { connection.setReadFrom(ReadFrom.REPLICA); @@ -92,7 +92,7 @@ void readWriteSlave() { } @Test - void readWriteSlavePreferred() { + void readWriteReplicaPreferred() { connection.setReadFrom(ReadFrom.REPLICA_PREFERRED); diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java b/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java index 87dc28e4f2..a9ff7bf82e 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterSetupTest.java @@ -472,7 +472,7 @@ public void expireStaleHostAndPortConnections() throws Exception { } @Test - public void readFromSlaveTest() { + public void readFromReplicaTest() { ClusterSetup.setup2Masters(clusterRule); RedisAdvancedClusterAsyncCommands clusterConnection = clusterClient.connect().async(); diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java b/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java index eba1bcd012..b3311c2986 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterStressScenariosTest.java @@ -75,7 +75,7 @@ public static void shutdownClient() { @Before public void before() { - ClusterSetup.setupMasterWithSlave(clusterRule); + ClusterSetup.setupMasterWithReplica(clusterRule); redis5 = client.connect(RedisURI.Builder.redis(host, ClusterTestSettings.port5).build()); redis6 = client.connect(RedisURI.Builder.redis(host, ClusterTestSettings.port6).build()); diff --git a/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java b/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java index 0463f7b47b..c56b6b7392 100644 --- a/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/models/slots/ClusterSlotsParserUnitTests.java @@ -59,7 +59,7 @@ void testParse() { } @Test - void testParseWithSlave() { + void testParseWithReplica() { List list = Arrays.asList(LettuceLists.newList("100", "200", LettuceLists.newList("1", "2", "nodeId1"), LettuceLists.newList("1", 2, "nodeId2"))); List result = ClusterSlotsParser.parse(list); @@ -78,11 +78,11 @@ void testParseWithSlave() { assertThat(clusterSlotRange.getSlaveNodes()).hasSize(1); - RedisClusterNode slaveNode = clusterSlotRange.getSlaveNodes().get(0); + RedisClusterNode replica = clusterSlotRange.getReplicaNodes().get(0); - assertThat(slaveNode.getNodeId()).isEqualTo("nodeId2"); - assertThat(slaveNode.getSlaveOf()).isEqualTo("nodeId1"); - assertThat(slaveNode.getFlags()).contains(RedisClusterNode.NodeFlag.SLAVE); + assertThat(replica.getNodeId()).isEqualTo("nodeId2"); + assertThat(replica.getSlaveOf()).isEqualTo("nodeId1"); + assertThat(replica.getFlags()).contains(RedisClusterNode.NodeFlag.SLAVE); } @Test diff --git a/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java b/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java index 018e573f38..21ced27a2e 100644 --- a/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java +++ b/src/test/java/io/lettuce/core/cluster/topology/TopologyComparatorsUnitTests.java @@ -296,7 +296,7 @@ void isChangedNodeIdChanged() { } @Test - void isChangedFlagsChangedSlaveToMaster() { + void isChangedFlagsChangedReplicaToMaster() { String nodes1 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 slave - 0 1401258245007 2 disconnected 8000-11999\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n"; @@ -309,7 +309,7 @@ void isChangedFlagsChangedSlaveToMaster() { } @Test - void isChangedFlagsChangedMasterToSlave() { + void isChangedFlagsChangedMasterToReplica() { String nodes1 = "3d005a179da7d8dc1adae6409d47b39c369e992b 127.0.0.1:7380 master - 0 1401258245007 2 disconnected 8000-11999\n" + "c37ab8396be428403d4e55c0d317348be27ed973 127.0.0.1:7381 master - 111 1401258245007 222 connected 7000 12000 12002-16383\n";